Every Security Header Your Site Needs (With Examples)
The complete list of HTTP security headers, what they do, and how to add them.
Security headers are free. There's no excuse for missing them.
Strict-Transport-Security (HSTS)
Tells browsers to only use HTTPS for your domain. Prevents downgrade attacks.
Strict-Transport-Security: max-age=31536000; includeSubDomains
Content-Security-Policy (CSP)
Controls which resources the browser can load. Prevents XSS attacks. This is the most complex header to configure.
X-Frame-Options
Prevents your site from being embedded in iframes on other domains. Stops clickjacking.
X-Frame-Options: DENY
X-Content-Type-Options
Prevents browsers from MIME-sniffing responses. Forces them to respect the declared content type.
X-Content-Type-Options: nosniff
Referrer-Policy
Controls how much referrer information is sent with requests. strict-origin-when-cross-origin is a good default.
Permissions-Policy
Controls which browser features your site can use (camera, microphone, geolocation). Deny everything you don't need.