HTTP security headers test
Enter a website address: its HTTP security headers (HSTS, CSP, X-Frame-Options, nosniff, Referrer-Policy, Permissions-Policy, cookies…) are checked one by one, with an overall grade and what to fix.
Understanding security headers
Why security headers?
These headers tell the browser how to protect itself when displaying your site: enforce HTTPS, refuse unexpected scripts, forbid framing by another site, never guess file types. They do not replace secure code, but they greatly limit the impact of a vulnerability.
HSTS: HTTPS with no exception
Strict-Transport-Security tells the browser to use HTTPS only for the given duration, even if a link or a typed address starts with http://. Start with a short duration, then move to one year (max-age=31536000) with includeSubDomains once every subdomain is on HTTPS.
Content-Security-Policy: the strongest protection
A CSP lists the origins allowed for scripts, styles, images or frames. Well tuned, it defeats most XSS flaws. Deploy it first as Content-Security-Policy-Report-Only to see what would be blocked, then enforce it. Avoid 'unsafe-inline' for scripts: use nonces or hashes instead.
Sample Nginx configuration
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; add_header X-Content-Type-Options nosniff always; add_header Referrer-Policy strict-origin-when-cross-origin always; add_header Content-Security-Policy "frame-ancestors 'self'" always; add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;
Frequently asked questions
Which security headers should I set first?
Strict-Transport-Security (HTTPS only), X-Content-Type-Options: nosniff and framing protection (frame-ancestors or X-Frame-Options) are easy and safe to add. A Content-Security-Policy gives the strongest protection against script injection, but needs testing, first in Report-Only mode.
How is the grade calculated?
Six headers count: HSTS, CSP, framing protection, nosniff, Referrer-Policy and Permissions-Policy. Each scores one point when correct, half a point when present but improvable. A site without HTTPS gets an F. An A+ also requires secure cookies and no software version leaks.
Where do I add these headers?
In your web server configuration (add_header in Nginx, Header set in Apache), your CDN or your application. Add them to every response, including error pages and redirects, then run the test again.
Does an F grade mean my site has been hacked?
No. The grade measures the protections the server asks the browser to enforce, not whether a vulnerability exists. A site graded F can be perfectly sound, but it is less able to defend itself if a flaw appears, in a plugin or a form for instance.
Why does the grade differ from one page to another?
Headers can vary between pages: an application, a CDN or a server rule may add them on some addresses only. Test the home page, but also the login page and the payment pages.