← All pwn.watch security tools
HTTP Security Headers Config Generator
Configure HSTS, Referrer-Policy, X-Content-Type-Options, X-Frame-Options, Permissions-Policy and Cross-Origin-Opener / Resource-Policy, then copy the config for Nginx, Caddy, Traefik, Cloudflare _headers or Next.js. Need a Content-Security-Policy? Use the CSP generator.
Presets:
nginx.conf (server block) · 7 headers
# inside server { ... } — `always` also adds headers to 4xx/5xx responses
# note: add_header in a location block replaces every add_header inherited from server
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Permissions-Policy "camera=(), microphone=(), geolocation=(), payment=(), usb=(), browsing-topics=(), interest-cohort=()" always;
add_header Cross-Origin-Opener-Policy "same-origin" always;
add_header Cross-Origin-Resource-Policy "same-site" always;- ⚠ COOP same-origin breaks OAuth / payment popups that call window.opener; use same-origin-allow-popups for those.
Tracking web server & framework CVEs? Check live advisories for nginx · Next.js · Cloudflare.
Sponsored
Brought to you byTinkerer Club
The private club for people who own their servers, run their own AI, and pay $0/month for software.
Security Headers Generator FAQ
- Which HTTP security headers should every site send?
- At minimum: Strict-Transport-Security, X-Content-Type-Options: nosniff, a Referrer-Policy such as strict-origin-when-cross-origin, framing protection (X-Frame-Options or CSP frame-ancestors) and a Permissions-Policy that disables features you do not use. Add a Content-Security-Policy with the CSP generator.
- When can I add the HSTS preload directive?
- Only when max-age is at least one year (31536000), includeSubDomains is set, and every subdomain serves HTTPS. The generator drops preload otherwise. Removal from browser preload lists takes months, so roll out with a short max-age first.
- Why does Nginx lose my headers inside a location block?
- Nginx only inherits add_header directives from the parent block when the child block defines none. If a location adds any header, repeat the security headers there (or use an include file). The always flag also sends them on 4xx/5xx responses.
- Will Cross-Origin-Opener-Policy break OAuth or payment popups?
- COOP same-origin severs window.opener for cross-origin popups, which breaks many OAuth and payment flows. Use same-origin-allow-popups on pages that open those popups.
- Is X-Frame-Options still needed if I use CSP frame-ancestors?
- Modern browsers prefer CSP frame-ancestors, but X-Frame-Options still protects older clients and costs nothing. Send both with matching values (DENY ↔ 'none', SAMEORIGIN ↔ 'self').
- How do I check which headers my site sends?
- Run curl -sI https://example.com and compare the response with the Raw headers tab, or open DevTools → Network → the document request → Response Headers.