LiveFor web & platform engineers

Security Header & CSP Builder

Generates Content-Security-Policy, HSTS, Permissions-Policy and related headers, with ready-to-paste config for Nginx, Apache, Caddy, Cloudflare and IIS.

Runs in your browser. Your data never leaves this device.
~/apps/security-header-builderruns in your browser · nothing uploaded
HTTPS (HSTS)
Content-Security-Policy

'self' is always included. Add the external origins each kind of resource loads from.

 
 
 
 
 
 
Who may embed your pages (frame-ancestors)
Where browsers send violation reports
Other headers
 
X-Frame-Options (older browsers)
Disable browser features (Permissions-Policy)
Server
Nginx · security-headers.conf
# Inside your server { } block. "always" also adds them to error responses.
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header Content-Security-Policy-Report-Only "default-src 'self'; script-src 'self' https://www.googletagmanager.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; img-src 'self' data: https:; font-src 'self' https://fonts.gstatic.com; connect-src 'self' https://*.google-analytics.com https://*.analytics.google.com; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'; upgrade-insecure-requests" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Permissions-Policy "camera=(), microphone=(), geolocation=(), payment=(), usb=(), browsing-topics=()" always;
add_header X-Frame-Options "DENY" always;
add_header Cross-Origin-Opener-Policy "same-origin" always;
Report-only mode logs violations but blocks nothing. Switch to enforcing once reports are clean
Report-only without a report URI only shows violations in the browser console
HeaderValue
Strict-Transport-Securitymax-age=31536000; includeSubDomains
Content-Security-Policy-Report-Onlydefault-src 'self'; script-src 'self' https://www.googletagmanager.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; img-src 'self' data: https:; font-src 'self' https://fonts.gstatic.com; connect-src 'self' https://*.google-analytics.com https://*.analytics.google.com; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'; upgrade-insecure-requests
X-Content-Type-Optionsnosniff
Referrer-Policystrict-origin-when-cross-origin
Permissions-Policycamera=(), microphone=(), geolocation=(), payment=(), usb=(), browsing-topics=()
X-Frame-OptionsDENY
Cross-Origin-Opener-Policysame-origin

Roll out in stages: start CSP in report-only mode, fix what it reports, then enforce. Test with your browser’s developer tools (Console and Network tabs).

What it does

  • All the important headersHSTS, Content-Security-Policy, X-Content-Type-Options, Referrer-Policy, Permissions-Policy, X-Frame-Options and cross-origin policies.
  • CSP made practicalAdd origins per resource type, toggle inline styles, and start in report-only mode.
  • Config for your serverReady-to-paste Nginx, Apache, Caddy, IIS, Cloudflare Pages / Netlify and Next.js configuration.
  • Warnings that matterExplains the risk of unsafe-inline, HSTS preload and cross-origin isolation before you deploy.

How to use it

  1. Start from the sample or the strict preset
  2. List the external origins your site loads from

    Check your browser’s Network tab for scripts, fonts and APIs.

  3. Pick your server and copy the configuration
  4. Deploy CSP in report-only mode, fix violations, then enforce

Questions people ask

Do I still need X-Frame-Options if I set frame-ancestors?

Modern browsers use CSP frame-ancestors and ignore X-Frame-Options when both are present. Keeping X-Frame-Options covers older browsers and some scanners.

Why start CSP in report-only mode?

A strict policy often blocks something you forgot, such as an analytics script or font. Report-only shows the violations without breaking the site, so you can fix the policy first.

What does HSTS preload do?

It adds your domain to a list built into browsers so they never connect over plain HTTP. It requires includeSubDomains and a max-age of at least a year, and removal takes months, so make sure every subdomain supports HTTPS first.

Last updated 4 Dec 2026 · More in Security & Compliance

More Security & Compliance tools

See all →
Your product here. Reach IT engineers and architects who use these tools.Advertise →