HTTP Security Configuration Generator
Pick a preset - Balanced, Strict, API backend or Legacy browsers - tune any of the nine
security headers, and get copy-ready configuration for the layer you actually run: an
nginx server block, Apache mod_headers directives, Cloudflare
Transform Rules, Django settings.py lines, an Express helmet
call or a FastAPI middleware. Every output carries a comment explaining each line, and
the reference table below explains what each header does and what breaks if you skip it.
Build your configuration
Start from a preset, then adjust any header. The output updates as you go.
=() on your origin. Tick only what your site does not use.Security header reference
What each header does, and what the risk is when it is missing.
| Header | What it does | Risk if missing |
|---|---|---|
| Strict-Transport-Security | Tells browsers to use HTTPS only, for max-age seconds; includeSubDomains extends it to subdomains; preload opts you into browser preload lists. | First visit can be intercepted (SSL stripping); users who type the domain land on plain HTTP until redirected. |
| X-Content-Type-Options | nosniff stops the browser from guessing a different MIME type than the one you declared. | A file served as image/svg+xml or text/html can execute script even when you never meant it to. |
| X-Frame-Options | DENY forbids framing anywhere; SAMEORIGIN allows framing from your own origin. Legacy header - CSP frame-ancestors is the modern replacement. | Clickjacking: an attacker frames your login page under a transparent layer and harvests clicks. |
| Referrer-Policy | Decides how much of your URL other sites receive in the Referer header, per navigation type. | Full URLs with tokens, session ids or private paths leak to every site you link out to. |
| Permissions-Policy | Gates browser features (camera, microphone, geolocation, payment, USB...) per origin and frame depth. | A malicious iframe on your page can request device features the user believes are off. |
| Cross-Origin-Opener-Policy | Isolates your browsing context group so cross-origin pages cannot read window properties of yours. | window.opener leaks and Spectre-class timing channels between your page and a malicious site. |
| Cross-Origin-Resource-Policy | Declares which origins are allowed to load your resources (images, fonts, APIs) in cross-origin contexts. | Other sites hotlink your assets, or worse, use your API endpoints as a confused oracle. |
| Cross-Origin-Embedder-Policy | Makes your origin refuse to load cross-origin subresources unless they explicitly allow it (COOP/CORS). | Nothing by itself - it is an opt-in hardening that unlocks stronger Spectre mitigations when combined with COOP. |
| Content-Security-Policy | Restricts where scripts, styles and other resources may load from; the strongest defence against XSS impact. | An injected script can do anything the victim's session can do. Every other header only limits the blast radius. |
What this tool does
Hardening a web service means setting the same nine or so HTTP response headers in
whatever layer actually answers the request - and getting the syntax right for each of
them. Nginx wants add_header ... always; inside a
server block, Apache wants
Header always set inside
<IfModule mod_headers.c>, Cloudflare wants one
Transform Rule per header in the dashboard, Django exposes most of them as
SECURE_* settings, and Express and FastAPI each have
their own idiom. This generator takes your choices once and emits all of those formats
at the same time, with a comment on every line explaining what it does, so the config
documents itself when the next person reads it.
How to use it
- Pick a preset. Balanced is the right default for a normal website: one-year HSTS with subdomains, nosniff, no framing, sensible referrer policy, device features locked. Strict adds preload, full isolation policies and a starter CSP - use it when you have time to test thoroughly. API backend is for JSON services that are consumed cross-origin, and Legacy browsers relaxes the isolation headers for older client support.
- Tune per header. Every control maps to one header. The one decision that genuinely needs your input is X-Frame-Options: if you embed your own pages in iframes (dashboards, admin panels), choose SAMEORIGIN or nothing; otherwise DENY.
- Choose your platforms. Tick only the layers you run. If you sit behind Cloudflare, generate the Cloudflare rules AND your origin config - then pick one layer to own each header and remove it from the other, so you never send a header twice.
- Copy or download. Each platform tab has its own Copy button; Download all gives you every selected platform in one text file for pasting into your repo's config directory.
Worked example
Say you run shop.example.com on nginx behind Cloudflare,
and the front end is a plain static build. Type the domain in, keep the Balanced
preset, untick Express and FastAPI, and generate. The Nginx tab gives you a
server block with five commented
add_header lines; drop it into your vhost, reload nginx,
and confirm with curl -sI https://shop.example.com that
the headers arrive. Then open the Cloudflare tab: create the matching Transform Rules
there so visitors who hit the edge directly get the same protection, and delete those
specific add_header lines from nginx - or keep them in
nginx and skip the Cloudflare rules. Either way, one layer owns each header. Finally,
run the output past the Security Headers Checker on this site to confirm nothing was
dropped in translation, and only then consider switching HSTS to the preload option.
How it works
The generator is a small state machine: your controls hold one value per header, and a
preset is just a saved set of values. On every change, the tool walks the active
headers in a fixed order - HSTS, nosniff, framing, referrer, permissions, then the
three isolation policies and CSP last - and renders each one through the template for
every checked platform. Nothing is parsed server-side and nothing leaves your browser;
the page works offline once loaded. The per-platform templates are deliberately
conservative: they emit the form each platform documents (nginx always
flag, Apache Header always set, helmet v7 option names,
Starlette middleware), so a copy-paste into a recent version of any of them works
without edits.
Common mistakes
- Enabling HSTS preload before you are ready. Once a domain is on the preload list, browsers refuse plain HTTP for it even on first visit - and removal takes weeks. Keep includeSubDomains off until every subdomain serves valid TLS, or one dead mail subdomain locks out the whole site.
- Sending the same header from two layers. Origin and edge both setting HSTS can produce duplicate values; strict clients reject the response. Pick one owner per header and document it in a comment (this generator's output does that for you).
- X-Frame-Options: DENY on a page you embed yourself. If your admin panel iframes a report from the same domain, DENY breaks it. Use SAMEORIGIN or move to CSP frame-ancestors with an explicit allow list.
- Turning on COEP require-corp for the excitement. It silently breaks every third-party script, font and image that does not send Cross-Origin-Resource-Policy back. Enable it only when you control all subresources (your own CDN) or use credentialless.
- A starter CSP on a site with inline scripts.
default-src 'self'will blank out any page that uses inline event handlers. Derive a real policy from your markup first - the CSP Header Builder on this site exists exactly for that step. - Forgetting error responses. Headers set only on 200s leave your 404 and 500 pages unprotected. That is why the nginx output uses
alwaysand Apache usesHeader always set.
Privacy
Everything on this page runs in your browser. The domain you type, the headers you tune and the configuration you generate are assembled locally as text - no request is made to any server with your input, nothing is stored, and there are no analytics calls attached to the tool itself. You can verify it: open your network tab, run the generator, and watch that only this page's own assets load.
Related tools
Suggested
Luke Keam | techgeek.biz