วิธีใช้: ตัวสร้าง Content-Security-Policy

ตัวสร้าง Content-Security-Policy คือเครื่องมือ เครื่องมือเว็บ ออนไลน์ฟรีที่ build a CSP header for nginx, Apache or HTML, with warnings about unsafe-inline and unsafe-eval ทันทีในเบราว์เซอร์ของคุณ วางข้อมูล ปรับตัวเลือก แล้วได้ผลแบบเรียลไทม์ — ไม่ต้องติดตั้ง ไม่ต้องสมัคร และไม่มีการอัปโหลดข้อมูล

ใช้ ตัวสร้าง Content-Security-Policy ทันที →

คำอธิบาย

Build a CSP header for nginx, Apache or HTML, with warnings about unsafe-inline and unsafe-eval.

  • เครื่องมือเว็บ
  • ด้วยการคำนวณฝั่งไคลเอ็นต์ทั้งหมด ตัวสร้าง Content-Security-Policy จึงปลอดภัยสำหรับข้อมูลที่ละเอียดอ่อน เช่น API key
ข้อมูลเข้า ตัวสร้าง Content-Security-Policy ข้อมูลออก ทำงาน 100% ในเบราว์เซอร์ของคุณ — ข้อมูลไม่ออกจากอุปกรณ์
ตัวสร้าง Content-Security-Policy — ข้อมูลเข้า → ข้อมูลออก

วิธีใช้

ใช้ ตัวสร้าง Content-Security-Policy ในสามขั้นตอน:

  1. วางข้อมูลในช่องอินพุต (หรือโหลดตัวอย่าง)
  2. ปรับตัวเลือกให้ตรงกับรูปแบบที่ต้องการ
  3. คัดลอก ดาวน์โหลด หรือตรวจสอบเอาต์พุต — อัปเดตทันทีขณะพิมพ์
วิธีใช้ · ตัวสร้าง Content-Security-Policy 1 วางข้อมูลในช่องอินพุต(หรือโหลดตัวอย่าง) 2 ปรับตัวเลือกให้ตรงกับรูปแบบที่… 3 คัดลอก ดาวน์โหลดหรือตรวจสอบเอาต์พุต —อัปเดตทันทีขณะพิมพ์
วิธีใช้

รัน

ตัวอย่าง

Fill in the directives; the generator emits nginx, Apache and meta-tag forms plus a Report-Only variant.

ข้อมูลออก(由工具此刻实时生成)

Content-Security-Policy

default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; connect-src 'self'; font-src 'self' data:; frame-src 'none'; object-src 'none'; base-uri 'self'; form-action 'self'; upgrade-insecure-requests

nginx
  add_header Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; connect-src 'self'; font-src 'self' data:; frame-src 'none'; object-src 'none'; base-uri 'self'; form-action 'self'; upgrade-insecure-requests" always;

Apache (.htaccess)
  Header always set Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; connect-src 'self'; font-src 'self' data:; frame-src 'none'; object-src 'none'; base-uri 'self'; form-action 'self'; upgrade-insecure-requests"

HTML meta tag
  <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; connect-src 'self'; font-src 'self' data:; frame-src 'none'; object-src 'none'; base-uri 'self'; form-action 'self'; upgrade-insecure-requests">

Report-only variant (test without breaking the site)
Content-Security-Policy-Report-Only: default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; connect-src 'self'; font-src 'self' data:; frame-src 'none'; object-src 'none'; base-uri 'self'; form-action 'self'; upgrade-insecure-requests

⚠ Review before deploying
  • No report-uri/report-to set — you will not learn about violations in production.

Always deploy with Report-Only first and watch the console for violations.

此输出由工具真实运行产生,并非人工编写。

กรณีใช้งาน

สถานการณ์ทั่วไปที่ ตัวสร้าง Content-Security-Policy ช่วยได้:

  • Build a CSP header for nginx, Apache or HTML, with warnings about unsafe-inline and unsafe-eval.

พารามิเตอร์

เครื่องมือนี้ไม่มีตัวเลือก ทำงานกับอินพุตโดยตรง

คำถามที่พบบ่อย

Content-Security-Policy Generator คืออะไร?

Content-Security-Policy Generator ใช้เพื่อbuild a CSP header for nginx, Apache or HTML, with warnings about unsafe-inline and unsafe-eval ทำงานทั้งหมดในเบราว์เซอร์ ข้อมูลของคุณเป็นส่วนตัว

Content-Security-Policy Generator ใช้ง่ายฟรีไหม?

ฟรี ไม่จำกัด ไม่ต้องสมัครหรือติดตั้ง

ข้อมูลของฉันถูกอัปโหลดไหม?

ไม่ ทุกอย่างประมวลผลในเครื่องของคุณ

ข้อควรรู้

  • 全部计算在浏览器端完成,因此超大输入受限于标签页内存,而非服务器上传限制。

เครื่องมือที่เกี่ยวข้อง

ตัวสร้าง Content-Security-Policy → · เครื่องมือเว็บ →

ใช้ ตัวสร้าง Content-Security-Policy ทันที →