Security Headers Generator
Generate a solid baseline set of HTTP security headers, Content-Security-Policy, HSTS, X-Frame-Options, Referrer-Policy and Permissions-Policy, with Nginx and Next.js snippets.
This Content-Security-Policy is a strict starting point, not a drop-in fit for every site. Test thoroughly: it will block any inline scripts, third-party scripts, or resources not explicitly allowed, and browsers will only report violations in the console rather than fail loudly.
Frequently asked questions
Why should I add these headers?+
They're one of the highest-leverage, lowest-effort ways to harden a site against common attacks like clickjacking, MIME-sniffing exploits, and cross-site scripting, and they're checked by tools like Mozilla Observatory and securityheaders.com.
Will the Content-Security-Policy break my site?+
Possibly, a strict CSP blocks any script, style, or resource source not explicitly allowed. Test carefully in a staging environment and check your browser console for violation warnings before deploying.
Should I enable HSTS before HTTPS is fully working?+
No, HSTS tells browsers to only ever connect over HTTPS for a long period (up to 2 years here), so enabling it before HTTPS is fully and reliably working can lock out visitors.