Secure Headers Baseline (Production Defaults)
On this page
Baseline Headers (Practical)
- Strict-Transport-Security (after HTTPS-only verified)
- X-Content-Type-Options: nosniff
- Referrer-Policy: strict-origin-when-cross-origin (common safe default)
- X-Frame-Options or CSP frame-ancestors (prefer CSP if you have CSP)
- Permissions-Policy (disable unused powerful features)
Nginx Example
add_header X-Content-Type-Options "nosniff" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; add_header X-Frame-Options "DENY" always; # Enable HSTS only after you are sure HTTPS is correct everywhere add_header Strict-Transport-Security "max-age=86400" always; # Minimal Permissions-Policy example (adjust to your app needs) add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always;
Verification
curl -sS -D - https://app.example.com/ -o /dev/null | egrep -i "strict-transport-security|x-content-type-options|referrer-policy|x-frame-options|permissions-policy"
Failure Modes
- Headers not on error responses: use always flag so 4xx/5xx still include headers.
- Multiple proxies: ensure headers are not stripped or duplicated incorrectly.
- Clickjacking exceptions: if embedding is needed, use CSP frame-ancestors with allowlist.
Operational Tip
Track header baseline in CI: run the curl check on every release and fail if headers regress.