Generate security response headers for nginx, Apache, Caddy, Next.js, Netlify or Vercel, with what each one does and the ones now superseded marked.
6 headers · 2 that can break things
The ones marked below need a decision rather than a default.
Once a browser has seen this, that visitor cannot reach the site over HTTP for 180 days. Lowering the value later only helps visitors who come back and receive the new header. Start at a few minutes, confirm nothing breaks, then raise it.
# Inside a server or location block.
# `always` matters: without it the header is skipped on error responses,
# which is exactly when a 404 page might reflect user input.
add_header Strict-Transport-Security "max-age=15552000; includeSubDomains" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header X-Frame-Options "DENY" always;
add_header Permissions-Policy "camera=(), microphone=(), geolocation=(), interest-cohort=()" always;
add_header Cross-Origin-Opener-Policy "same-origin" always;Strict-Transport-Securitycan break thingsTells the browser to use HTTPS for this host for the next max-age, without asking.
It only applies after the first successful HTTPS response, so it does not protect a visitor's very first request. That gap is what the preload list closes.
X-Content-Type-OptionsStops the browser guessing a response's type from its content instead of its Content-Type.
Cheap and worth setting everywhere. It closes the case where a user-uploaded file served as text/plain gets executed as script because its bytes look like HTML.
Referrer-PolicyControls how much of the current URL is sent when the visitor follows a link out.
It protects the path and query string, which routinely contain tokens and identifiers. It does nothing about the destination learning your origin, which strict-origin-when-cross-origin still sends.
X-Frame-OptionsThe older clickjacking defence.
Superseded by the CSP frame-ancestors directive, which is more expressive and is what current browsers prefer. Worth keeping only for very old clients, and the two must agree or the behaviour depends on the browser.
Permissions-PolicySwitches off browser features this page does not use, for the page and anything it frames.
An empty allowlist means nobody, including your own origin. If a feature is later added to the page it fails silently until the header is updated, which is the usual way this one causes a confusing bug.
Cross-Origin-Opener-Policycan break thingsSevers the window reference between this page and anything it opens cross-origin.
It breaks OAuth and payment flows that rely on window.opener to post a result back. Check those before enabling it.
Note the always on every line. Without it nginx skips the header on error responses — which is exactly when a 404 page might be reflecting something a visitor typed.
This is a commitment, not a setting. Once a browser has seen it, that visitor cannot reach the site over HTTP for 180 days, and lowering max-age later only helps visitors who come back and receive the new header. Start at a few minutes, confirm nothing breaks, then raise it.
includeSubDomains covers EVERY subdomain, including ones you may not be thinking about — an internal tool on http://staging.example.com stops loading for anyone who has visited the main site.
Headers are a floor, not a security review. None of these stops a vulnerability in the application itself, and a site can set all of them and still leak data through its own endpoints.
These are a floor, not a security review. None of them stops a vulnerability in your own application, and a site can set every one of them and still leak data through its own endpoints. The one that genuinely stops an attack in progress is a strict Content Security Policy, which has its own tool because it needs to be tuned against a real page.
Security Headers Generator runs entirely on your device — nothing is fetched or uploaded.
You’re on the Free plan. Compare plans
The same set of headers in six server syntaxes, because getting the header right and the configuration syntax wrong is the usual outcome. nginx needs `always` on `add_header` or the header is dropped on error responses — which is exactly when a security header matters.
HSTS comes with its consequence stated rather than a recommended value. `max-age` is a commitment: for that long, browsers that have seen the header will refuse plain HTTP to your domain, and there is no way to retract it early. With `includeSubDomains` that extends to every subdomain, including the internal one somebody set up on HTTP. Starting with a short max-age and raising it is the reversible path.
`preload` is flagged more strongly, because submitting to the browser preload list is close to permanent: removal takes months to propagate and affects every browser that ships the list.
Superseded headers are marked as such. `X-XSS-Protection` is ignored by current browsers and was itself a source of vulnerabilities; `X-Frame-Options` is superseded by CSP's `frame-ancestors` but still worth keeping for older clients. Which of those two is which is the kind of thing a generator should tell you.
Nothing is deployed and no site is contacted. This generates configuration text to review.
Start small — a day or a week — and raise it once you are confident every subdomain is on HTTPS. The value is a promise browsers keep: for that long they will refuse plain HTTP to your domain, and you cannot shorten it for a browser that already saw the longer value.
Only if you are certain. Preloading ships your domain in the browser's own list, which protects the very first visit — and removal takes months to reach users. It is close to a permanent commitment that every subdomain will be HTTPS for ever.
CSP's `frame-ancestors` supersedes it and is more flexible, but X-Frame-Options is still honoured by older clients and costs nothing. Set both; where they disagree, browsers that support both use the CSP directive.
Because without it the header is only added to successful responses. Error pages — the 500 your application returns when something has gone wrong — would go out without your security headers, which is the worst possible time to drop them.
No. Nothing is fetched and nothing is deployed. You get configuration text to review and apply yourself.