Security headers generator
Choose your server and options, and copy a complete block of HTTP security headers: HSTS, Content-Security-Policy, clickjacking protection, X-Content-Type-Options, Referrer-Policy and Permissions-Policy, with the server's version hidden. The defaults pass audibot's security header checks.
The configuration is written in your browser. Nothing you type is sent anywhere.
Your configuration
nginx
Inside the HTTPS server { } block. A location block with an add_header of its own drops these, so repeat them there.
Apache
The Header lines go in the HTTPS <VirtualHost>, with mod_headers enabled (a2enmod headers). ServerTokens is refused inside a <VirtualHost> or .htaccess, so it goes in the main server config.
Caddy
Inside the site block of your Caddyfile. Caddy serves HTTPS by default.
Netlify
A file named _headers in the publish directory. Netlify does not put a version in its Server header.
Vercel
vercel.json at the root of the project; merge "headers" into an existing file. Vercel does not put a version in its Server header.
Cloudflare Pages
A file named _headers in the build output directory. Cloudflare does not put a version in its Server header.
Raw HTTP headers
The headers every HTTPS response should carry, for any other server or framework. Turn version numbers off in each layer that adds a Server or X-Powered-By header.
Deployed it? Check that the headers are really served
A header in a config file is not always a header on the response: a proxy, a CDN or a second add_header can drop it. The security headers checker reads what your home page actually sends.
Reports are public. A site audibot has already checked shows its stored result; a new one runs the full passive audit, the first without an account. The security headers score also counts cookie flags and security.txt, which are not headers this page writes.
What each header does
- Strict-Transport-Security (HSTS) header — Without HSTS, a browser that is sent to http:// will make that plain request first, and someone on the same network can answer it instead of the site. HSTS tells the browser to use HTTPS for this host for
max-ageseconds without asking. - Content-Security-Policy header — A CSP lists where the page may load scripts, styles and other resources from. If an attacker manages to inject markup into the page (cross-site scripting), the browser refuses to run a script the policy does not allow.
'unsafe-inline'allows exactly the kind of script an injection produces, so most of the protection is gone. - X-Content-Type-Options: nosniff — Without it, a browser may ignore the declared Content-Type and guess from the content — treating an uploaded text file as a script, for example.
nosniffmakes it trust the declared type. - Clickjacking protection (frame-ancestors / X-Frame-Options) — Clickjacking loads a page in an invisible frame on top of another site and lines a button up under the visitor's cursor, so a click meant for the visible page lands on yours — while they are signed in to it.
- Referrer-Policy header — The Referer header tells the next site which page a visitor came from — sometimes including a path or query string that names an account, a search or a token. An explicit policy decides how much leaves the site instead of leaving it to each browser.
- Permissions-Policy header — Permissions-Policy switches browser features — camera, microphone, geolocation, payment and others — off for the page and every frame in it. If a third-party script or an injected one asks for them, the browser refuses before the visitor is prompted.
- Software versions in response headers — An exact version tells anyone which published vulnerabilities apply without them having to probe. Hiding it does not patch anything, but it stops the site from advertising which patches it is missing.
Questions
How do I add an HSTS header, and what max-age should it have?
Send the header on every HTTPS response. 31536000 (a year) is the usual value. Add includeSubDomains only once every subdomain serves HTTPS, because browsers will refuse plain HTTP on all of them.
What is a good Content-Security-Policy, and how do I add one?
Start strict and loosen only for what the site really loads. Send the policy as Content-Security-Policy-Report-Only first, fix what the browser console reports, then send the same value as Content-Security-Policy. Move inline <script> blocks into files, or allow them with a per-response nonce or a hash.
How do I stop my site from being framed (clickjacking)?
frame-ancestors is the current mechanism; X-Frame-Options is the older one that every browser still honours. Sending both is harmless. Use 'none' / DENY if the site is never framed, 'self' / SAMEORIGIN if it frames itself.
Which Referrer-Policy should I use, and how do I set it?
strict-origin-when-cross-origin sends the full URL within the site, only the origin to other HTTPS sites, and nothing to plain HTTP. Use no-referrer if other sites never need to know where traffic came from.
How do I add a Permissions-Policy header?
List the features the site does not use with an empty allowlist (). A feature the site does use can be limited to itself with (self).
How do I hide the server version in HTTP headers?
Turn version disclosure off in each layer that adds a header: the web server, the language runtime and the framework.
Generate security.txt or check security.txt and its expiry.