./prontouso.com
BẢO MẬT & RIÊNG TƯ

Trình Tạo Header Content Security Policy (CSP)

Tạo các chỉ thị Content Security Policy (CSP) chuẩn (default-src, script-src, style-src, img-src, connect-src, frame-ancestors) giúp bảo vệ trang web của bạn khỏi các cuộc tấn công tiêm mã độc (XSS) và chèn khung lừa đảo (clickjacking).

Trạng thái công cụChạy trên trình duyệt của bạn
Xem trước
prontouso://security/csp-generator
HEADER · NGINX · APACHE · METAAUTO GENERATE

Start from a profile

Pick a starting point, then fine-tune each directive below. Switching profiles keeps whatever you've already typed in directives it doesn't mention.

POLICY
default-src
Fallback source list for any directive not set explicitly below.
'self'
Quick add
script-src
Where JavaScript may be loaded and executed from.
'self'
Quick add
style-src
Where stylesheets and inline <style> may come from.
'self'
Quick add
img-src
Where images may be loaded from.
'self'data:
Quick add
font-src
Where @font-face fonts may be loaded from.
'self'
Quick add
connect-src
Allowed targets for fetch, XHR, WebSocket and EventSource.
'self'
Quick add
worker-src
Where Worker/SharedWorker/ServiceWorker scripts may load from.
Off — the browser uses the applicable fallback, when this directive has one.
frame-src
Allowed sources for embedded <frame>/<iframe> content.
'none'
Quick add
object-src
Allowed sources for <object>/<embed>/<applet>. Leave at 'none' unless you need Flash-era plugins.
'none'
Quick add
base-uri
Restricts what a <base> tag is allowed to point to, blocking a common injection trick.
'self'
Quick add
form-action
Allowed targets for HTML form submissions.
'self'
Quick add
frame-ancestors
Who may embed this page in a frame — the CSP replacement for X-Frame-Options.
'none'
Quick add
Violation reporting
● NO LOGIN · PROCESSED LOCALLY

Generated policy

Pick the format that matches where you're deploying this.

ĐẦU RA
Policy health

Automatic checks against common CSP mistakes.

No obvious weaknesses found in the enabled directives.
HTTP header
Content-Security-Policy-Report-Only: default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; font-src 'self'; connect-src 'self'; frame-src 'none'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none';
Test an origin

Check whether a given URL would be allowed under the directive you pick, using the policy above.

Resource type
URL to test
Rollout checklist
1. Ship this Report-Only header — nothing on the site breaks yet.
2. Collect reports for several days of real traffic before touching anything.
3. Adjust the directives above for any legitimate resource that shows up blocked.
4. Once reports come back clean, switch the mode to Enforce.

Cách thức hoạt động

  1. Nhập dữ liệu của bạn

    Điền các giá trị cần thiết, dán văn bản hoặc tải lên tệp bạn muốn xử lý.

  2. Xem kết quả tức thì

    Hầu hết các công cụ cập nhật theo thời gian thực khi bạn nhập liệu; một số công cụ sử dụng một nút hành động duy nhất.

  3. Sử dụng kết quả

    Sao chép, tải xuống hoặc chia sẻ kết quả được tạo — bạn luôn có toàn quyền kiểm soát dữ liệu của mình.

Quyền riêng tư & xử lý dữ liệuChạy cục bộ 100% trên trình duyệt của bạn. Công cụ này không tải dữ liệu của bạn lên máy chủ.

Trình Tạo Header Content Security Policy (CSP) là gì?

Trình tạo CSP là tiện ích bảo mật web giúp bạn xây dựng và kiểm tra chuỗi tiêu đề Content-Security-Policy vững chắc cho website của mình.

TÌM HIỂU CÁCH HOẠT ĐỘNG CỦA CÔNG CỤ

Hướng Dẫn Thiết Lập Header Content Security Policy (CSP)

Tìm hiểu cách cấu hình các chỉ thị CSP (script-src, style-src, default-src) nhằm ngăn chặn tấn công tiêm mã độc XSS và chèn khung lừa đảo.

Các chỉ thị nền tảng trong CSP

Sử dụng 'default-src 'self'' làm quy tắc nền tảng nghiêm ngặt, sau đó chỉ định cụ thể các tên miền được phép tải tài nguyên JavaScript, CSS, hình ảnh và API.

Quyền Riêng Tư & Xử Lý Dữ Liệu

Quá trình tạo chuỗi cấu hình header CSP diễn ra 100% trên trình duyệt của bạn.

Các Câu Hỏi Thường Gặp (FAQ)

Chế độ Content-Security-Policy-Report-Only là gì?

Chế độ Report-Only ghi nhận các vi phạm chính sách gửi về endpoint theo dõi mà không chặn việc thực thi tài nguyên, rất hữu ích cho giai đoạn thử nghiệm.

Công Cụ Liên Quan