Security Headers Generator
Build a complete set of HTTP security headers — HSTS, Content-Security-Policy, clickjacking and cross-origin protections — and copy a ready-to-paste config for your server.
Start from a preset
Scan your site (optional)
Fetch your domain's live headers to see which are missing, then apply the recommended fixes in one click.
Strict-Transport-Security (HSTS)
Forces browsers to only ever connect over HTTPS.
X-Frame-Options
Stops other sites from embedding yours in a frame (clickjacking).
X-Content-Type-Options
Sends nosniff to stop browsers guessing file types.
Referrer-Policy
Controls how much of your URL is shared when users click away to another site.
Permissions-Policy
Decides which browser features (camera, microphone, geolocation…) your pages may use.
Features you don't set are left unrestricted. "block" = (), "self" = (self), "all" = *.
Cross-Origin policies
Isolate your pages from other origins. COEP require-corp can break third-party embeds.
Content-Security-Policy
The strongest defence against cross-site scripting — control exactly which sources a page may load.
Optional. Where browsers POST a JSON report whenever the policy is violated.
Resulting policy
default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; font-src 'self' data:; connect-src 'self'; frame-ancestors 'self'; base-uri 'self'; form-action 'self'; object-src 'none'; upgrade-insecure-requests
Your configuration
- frame-ancestors supersedes X-Frame-Options in modern browsers; X-Frame-Options is kept for legacy only.
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; add_header Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; font-src 'self' data:; connect-src 'self'; frame-ancestors 'self'; base-uri 'self'; form-action 'self'; object-src 'none'; upgrade-insecure-requests" always; add_header X-Frame-Options "SAMEORIGIN" 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=()" always; add_header Cross-Origin-Opener-Policy "same-origin" always; add_header Cross-Origin-Resource-Policy "same-origin" always;
What each header does
Strict-Transport-Security (HSTS) tells browsers to only ever talk to your site over HTTPS, so an attacker can't downgrade a visitor to plain HTTP.
Content-Security-Policy (CSP) is an allowlist of where scripts, styles, images and other resources may come from. A good CSP is the single most effective defence against cross-site scripting (XSS).
X-Frame-Options (and CSP's frame-ancestors) stop other sites from loading yours inside an invisible frame to trick your users into clicking things — a clickjacking attack.
X-Content-Type-Options: nosniff stops browsers from second-guessing a file's type, which can otherwise turn an uploaded image into an executable script.
Referrer-Policy limits how much of your URL is leaked to other sites when a user clicks an outbound link.
Permissions-Policy switches off powerful browser features (camera, microphone, geolocation) your site doesn't need, shrinking what a compromised page could abuse.
Cross-Origin policies (COOP/COEP/CORP) isolate your pages from other origins. They're required to unlock high-precision timers and SharedArrayBuffer, but require-corp can break third-party embeds, so test carefully.