Security headers generator: which response headers should my site send?
How does this check work, and what does the result tell you?
AdminKit's security headers generator builds ready-to-paste HSTS, Content-Security-Policy, X-Content-Type-Options, Referrer-Policy, Permissions-Policy and Cross-Origin-Opener-Policy headers from the options you tick, as nginx, Apache, Caddy and _headers config. It runs entirely in your browser: nothing is sent to any server, and it never contacts your site.
Part of the Security basics cluster — more tools, guides and terms on security basics.
Added after 'self'. Separate with spaces; leave empty to fall back to default-src.
Added after 'self'. Separate with spaces; leave empty to fall back to default-src.
Added after 'self'. Separate with spaces; leave empty to fall back to default-src.
Added after 'self'. Separate with spaces; leave empty to fall back to default-src.
Built entirely in your browser — nothing you tick or type is sent to AdminKit or any other server, and this tool does not contact your site. X-XSS-Protection is left out on purpose: it is deprecated.
Header lines (what the browser receives)
Strict-Transport-Security: max-age=31536000 Content-Security-Policy-Report-Only: default-src 'self'; object-src 'none'; base-uri 'self'; frame-ancestors 'none'; upgrade-insecure-requests X-Content-Type-Options: nosniff Referrer-Policy: strict-origin-when-cross-origin Permissions-Policy: camera=(), microphone=(), geolocation=() Cross-Origin-Opener-Policy: same-origin
nginx (server or location block)
add_header Strict-Transport-Security "max-age=31536000" always; add_header Content-Security-Policy-Report-Only "default-src 'self'; object-src 'none'; base-uri 'self'; frame-ancestors 'none'; upgrade-insecure-requests" always; add_header X-Content-Type-Options "nosniff" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always; add_header Cross-Origin-Opener-Policy "same-origin" always;
Apache (needs mod_headers)
Header always set Strict-Transport-Security "max-age=31536000" Header always set Content-Security-Policy-Report-Only "default-src 'self'; object-src 'none'; base-uri 'self'; frame-ancestors 'none'; upgrade-insecure-requests" Header always set X-Content-Type-Options "nosniff" Header always set Referrer-Policy "strict-origin-when-cross-origin" Header always set Permissions-Policy "camera=(), microphone=(), geolocation=()" Header always set Cross-Origin-Opener-Policy "same-origin"
Caddy (inside the site block)
header {
Strict-Transport-Security "max-age=31536000"
Content-Security-Policy-Report-Only "default-src 'self'; object-src 'none'; base-uri 'self'; frame-ancestors 'none'; upgrade-insecure-requests"
X-Content-Type-Options "nosniff"
Referrer-Policy "strict-origin-when-cross-origin"
Permissions-Policy "camera=(), microphone=(), geolocation=()"
Cross-Origin-Opener-Policy "same-origin"
}_headers file (Cloudflare Pages, Netlify)
/* Strict-Transport-Security: max-age=31536000 Content-Security-Policy-Report-Only: default-src 'self'; object-src 'none'; base-uri 'self'; frame-ancestors 'none'; upgrade-insecure-requests X-Content-Type-Options: nosniff Referrer-Policy: strict-origin-when-cross-origin Permissions-Policy: camera=(), microphone=(), geolocation=() Cross-Origin-Opener-Policy: same-origin
Generating the config changes nothing by itself: add it to your server, reload, then check what the site really sends with AdminKit's HTTP security headers check.
What the result means
The header lines are what a browser receives; the nginx, Apache, Caddy and _headers snippets send exactly those headers. The Content-Security-Policy starts as Report-Only, which reports problems without blocking anything, until you untick it.
Next step
Add the snippet to your server config, reload, then check what the site really sends with AdminKit's HTTP security headers check. For the plain-language definition of CSP, see the Content Security Policy glossary entry.
Keep this result
Copy a link to this check so you can share it or run it again later. Want a heads-up when this result changes? Talk to our team and we'll set it up for you.
How it works and limits
Tick the headers you want, pick a value for each, add any extra sources your pages load scripts, styles, images or API calls from, and this tool writes the matching config as you go, entirely in your browser. Nothing you tick or type is sent to AdminKit or any other server, and the tool never contacts your site. It is the “fix it” companion of AdminKit’s HTTP security headers check: that check fetches a URL live and shows which headers are missing; this generator gives you lines to paste into your web server, then you run the check again to confirm the site really sends them.
What does the generator output?
The default output, before you change anything, is these header lines:
Strict-Transport-Security: max-age=31536000
Content-Security-Policy-Report-Only: default-src 'self'; object-src 'none'; base-uri 'self'; frame-ancestors 'none'; upgrade-insecure-requests
X-Content-Type-Options: nosniff
Referrer-Policy: strict-origin-when-cross-origin
Permissions-Policy: camera=(), microphone=(), geolocation=()
Cross-Origin-Opener-Policy: same-origin
The same headers come out in four formats:
- nginx — one add_header line per header, each ending in
always;. The nginx headers module adds a header only to a short list of success and redirect status codes unless the always parameter is given. It also notes that add_header lines are inherited from the outer level only when the current level defines none, so a single add_header inside a location block drops all of these from that location. - Apache — one
Header always setline per header, which needs mod_headers loaded. The mod_headers documentation explains that the always table also applies to error responses and internal redirects, where the default onsuccess table does not. - Caddy — one header block for your site block. The Caddy header directive sets (overwrites) a field when the name has no prefix, which is what the snippet uses.
- _headers file — a path line followed by indented “Name: value” lines, the format Cloudflare Pages and Netlify read from the site’s build output (publish) directory. Cloudflare documents a limit of 100 header rules and 2,000 characters per line; the tool warns if a line goes over that length.
Which headers does it cover, and with what defaults?
| Header | Default | What you can change |
|---|---|---|
| Strict-Transport-Security | max-age 1 year | max-age, includeSubDomains, preload |
| Content-Security-Policy | Report-Only starter policy | enforce, extra sources, frame-ancestors |
| X-Content-Type-Options | nosniff | on or off |
| Referrer-Policy | strict-origin-when-cross-origin | any standard value, or not sent |
| Permissions-Policy | camera, microphone, geolocation off | allow each for your own origin |
| Cross-Origin-Opener-Policy | same-origin | same-origin-allow-popups, unsafe-none, or not sent |
| X-Frame-Options | not sent | legacy fallback, DENY or SAMEORIGIN |
Strict-Transport-Security (HSTS) tells browsers to use only HTTPS for your host. MDN’s Strict-Transport-Security reference notes that browsers ignore the header when it arrives over plain HTTP, so it only takes effect once a visitor has reached the site over HTTPS. For a first rollout, a short max-age such as 300 seconds limits how long a mistake sticks; raise it once everything works.
Content-Security-Policy (CSP) limits where a page may load scripts, styles, images and other resources from. The starter policy allows your own origin, blocks plugins (object-src ‘none’), pins base-uri to your origin, controls who may frame the page, and, with upgrade-insecure-requests, asks the browser to treat the page’s plain-HTTP URLs as HTTPS.
X-Content-Type-Options: nosniff stops browsers from guessing a different content type than the one the server declares. Referrer-Policy controls how much of the page URL travels to other sites in the Referer header; strict-origin-when-cross-origin sends only the origin to other sites and nothing on an HTTPS-to-HTTP step. Permissions-Policy turns browser features off for your page and any frames in it; an empty list, as in camera=(), blocks the feature everywhere.
Cross-Origin-Opener-Policy separates your page from windows it opens or that open it. MDN’s Cross-Origin-Opener-Policy reference describes same-origin-allow-popups as the relaxed value for pages that open a trusted cross-origin service, for example for OAuth sign-in or payments, and still need a reference to that window. If a sign-in or payment popup stops working after you deploy same-origin, switch to that value.
Why ship the CSP as Report-Only first?
A Content-Security-Policy usually breaks something on first deploy: an inline script in a template, a font from a CDN, an analytics or chat widget, an image on another host. The Report-Only toggle is on by default, so the output uses the Content-Security-Policy-Report-Only header name with exactly the same policy. MDN’s Content-Security-Policy-Report-Only reference describes it as a way to test or repair violations before the policy is enforced, and notes that reports are only sent when the policy names a report-to endpoint. This generator does not add one. When the pages you care about work under the policy, untick Report-Only to switch the header name to the enforcing Content-Security-Policy.
How are the CSP source fields validated?
Each allow-list field (script-src, style-src, img-src, connect-src) takes extra sources separated by spaces; the tool puts ‘self’ in front of them. An empty field adds no directive, so default-src ‘self’ applies. Each source must be one of:
- a host, with or without scheme, port and path:
cdn.example.com,*.example.com, or a full URL such as the one in the example below; - a scheme such as
https:,data:orblob:; - a quoted keyword from the CSP list: ‘self’, ‘none’, ‘unsafe-inline’, ‘unsafe-eval’, ‘strict-dynamic’, ‘unsafe-hashes’, ‘report-sample’, ‘wasm-unsafe-eval’;
- a quoted nonce or hash: ‘nonce-’ or ‘sha256-’, ‘sha384-’, ‘sha512-’ followed by a base64 value of the right length for that hash.
script-src 'self' https://cdn.example.com 'sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU='
A field containing a newline is rejected, and so is any source containing a semicolon, a comma, a double quote, a backslash, a dollar sign, a percent sign or braces. Those characters could end the directive, split the header, break out of the quoted string in the snippet, or be read as a variable by nginx, Apache or Caddy. An unquoted self or none is rejected with a hint to quote it, and ‘none’ cannot be combined with other sources. Sources with ‘unsafe-inline’, ‘unsafe-eval’, or a whole scheme or every host in script-src are allowed but get a warning.
What about HSTS preload, X-Frame-Options and X-XSS-Protection?
Preload. The HSTS preload list submission site lists the requirements: a valid certificate, a redirect from HTTP to HTTPS on the same host, every subdomain served over HTTPS (including internal subdomains that are not publicly reachable), and an HSTS header on the base domain with max-age of at least 31536000 seconds, includeSubDomains and preload. It also warns that inclusion cannot easily be undone: removal takes months to reach users with a browser update. Ticking preload here therefore adds includeSubDomains and raises max-age to 31536000 if you chose less, and shows a warning. Submitting the domain is a separate step on hstspreload.org; the header alone does not put you on the list.
X-Frame-Options is superseded by the CSP frame-ancestors directive. MDN’s X-Frame-Options reference points to frame-ancestors for more complete control. The generator offers X-Frame-Options only as a legacy fallback, off by default, and sets it to DENY or SAMEORIGIN to match your frame-ancestors choice.
X-XSS-Protection is never emitted. MDN’s X-XSS-Protection reference marks it deprecated and warns that it can create cross-site scripting vulnerabilities in otherwise safe websites. MDN adds that it is largely unnecessary in modern browsers when the site sends a strong CSP that disables inline JavaScript.
Example: nginx config for a site with a CDN
With HSTS at two years plus includeSubDomains, CSP enforced with images from data: URLs, frame-ancestors ‘self’,
Referrer-Policy no-referrer, geolocation allowed for your own origin, COOP same-origin-allow-popups and the
legacy X-Frame-Options fallback on, the nginx output is:
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" always;
add_header Content-Security-Policy "default-src 'self'; img-src 'self' data:; object-src 'none'; base-uri 'self'; frame-ancestors 'self'; upgrade-insecure-requests" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "no-referrer" always;
add_header Permissions-Policy "camera=(), microphone=(), geolocation=(self)" always;
add_header Cross-Origin-Opener-Policy "same-origin-allow-popups" always;
add_header X-Frame-Options "SAMEORIGIN" always;
Limits
- This tool only writes text. It never contacts your site, so it cannot tell which headers you send today or whether the CSP fits your pages; reload your server and run the HTTP security headers check for that.
- The CSP is a starter policy. It does not cover every directive (for example form-action, worker-src or report-to), and it cannot know which third-party scripts your pages load.
- It does not check that hosts you type exist or belong to you; it only checks their syntax.
- It writes one header set for one path pattern. Sites that need different headers per path need one block per path in the server config.
The OWASP Secure Headers Project provides technical information and tools about HTTP security headers and is a good next read for the headers this tool does not cover. For the plain-language definitions, see Content Security Policy, Referrer-Policy and the guide to HSTS and HSTS preload. This tool is part of AdminKit’s security basics cluster, next to the security.txt generator and the SSL/TLS check.
Frequently asked questions
Does this tool send my settings or my site address anywhere?
No. Every option is read by your browser and the config is built there with plain JavaScript; nothing is sent to AdminKit or any other server, and the tool never contacts your site. That also means it cannot see which headers your site sends today; AdminKit's HTTP security headers check does that as a separate, live step.
Why does the CSP start as Content-Security-Policy-Report-Only?
A new Content-Security-Policy often blocks something the site needs on first deploy, such as an inline script, a web font or an analytics call. The Report-Only header applies the same policy without blocking anything, so you can find what would break and add those sources first. MDN notes that reports are only sent when the policy has a report-to directive; this generator does not add one, so set up a reporting endpoint yourself if you want reports collected.
Why is X-XSS-Protection not in the output?
MDN marks X-XSS-Protection as deprecated and warns that it can create cross-site scripting vulnerabilities in otherwise safe websites. MDN adds that the protection is largely unnecessary in modern browsers when a site sends a strong Content-Security-Policy that disables inline JavaScript, so this generator never emits X-XSS-Protection: 1.
Should I tick HSTS preload?
Only if every subdomain, including internal ones, will stay on HTTPS for the long term. hstspreload.org requires max-age of at least 31536000 seconds, includeSubDomains and preload, and warns that inclusion cannot easily be undone: removal takes months to reach users. Ticking preload here forces includeSubDomains and a one-year max-age for that reason.
Do I still need X-Frame-Options?
Not in current browsers if you send a CSP with frame-ancestors; MDN points to frame-ancestors for more complete control over who may frame a page. The generator offers X-Frame-Options only as a legacy fallback, set to DENY or SAMEORIGIN to match the frame-ancestors choice.