Guides · Security headers

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.

Add includeSubDomains only once every subdomain serves HTTPS, because browsers will refuse plain HTTP on all of them.

preload is written only with includeSubDomains and a max-age of at least 31536000 (a year), the minimum the preload list accepts.

HSTS guide

Starts from the policy in the guide: default-src 'self'; img-src 'self' data:; object-src 'none'; base-uri 'self'. Add the origins the site really loads from, separated by spaces.

Scores as a warning: An enforced policy allows 'unsafe-inline' scripts with no nonce or hash, or only a report-only policy is set.

Content-Security-Policy guide

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. The value follows the frame-ancestors choice above.

Clickjacking protection guide

X-Content-Type-Options guide

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.

Referrer-Policy guide

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).

Permissions-Policy guide

Turn version disclosure off in each layer that adds a header: the web server, the language runtime and the framework. The output covers the web server: server_tokens off, ServerTokens Prod or -Server.

Software versions guide

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

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.

Read the full guide

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.

Read the full guide

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.

Read the full guide

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.

Read the full guide

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).

Read the full guide

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.

Read the full guide

Generate security.txt or check security.txt and its expiry.

Related tools

All free tools