Skip to content
shellhacks.dev

Security Headers Generator

Choose HSTS, CSP, X-Content-Type-Options, X-Frame-Options, Referrer-Policy, Permissions-Policy and COOP, and get the config for Nginx, Apache, Caddy, Laravel or Express.

Free · No sign-up · Your inputs stay in your browser

Input

Generate HTTP security headers

Output

Configuration

7 headers

In Nginx, add_header in a location block replaces every add_header inherited from server, so a location with its own header silently drops all of these; repeat them or use an include. always also sends them on 4xx and 5xx responses. X-XSS-Protection is deliberately absent: modern browsers ignore it.

Runs in this browser. Nothing you paste is sent to a server.

The baseline

Strict-Transport-Security makes browsers use HTTPS for your host from then on. X-Content-Type-Options: nosniff stops content-type guessing. A Content-Security-Policy or X-Frame-Options blocks clickjacking. Referrer-Policy limits what leaks in the Referer header, and Permissions-Policy switches off browser features you do not use. The OWASP Secure Headers Project keeps current recommendations.

The Nginx inheritance trap

Nginx's add_header directives are inherited from the server block only if the location block defines none of its own. Add a single header inside a location and every security header from the server block disappears for that location. Put them in a file and include it in each place, and add always so error responses carry them too.

HSTS preload

Preloading puts your domain in browsers' built-in HTTPS list. Removal takes months to reach users, so enable it only when every subdomain serves HTTPS for good.

Share

Frequently asked questions

Do I still need X-XSS-Protection?
No. Modern browsers removed the XSS auditor it controlled, and the header can introduce bugs in old ones. A CSP is the replacement.
What max-age should HSTS use?
Start with a short one, such as 300 seconds, to test, then raise it to at least a year (31536000). Preload lists require a year or more.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Go deeper

Suggested reading

Keep planning

Similar tools