Security headers are low-effort, high-impact hardening for any web server. Our generator outputs the add_header directives for HSTS, nosniff, framing, referrer and permissions policy, and the cross-origin isolation headers. Content-Security-Policy has its own generator.
HSTS, X-Content-Type-Options, X-Frame-Options (or CSP frame-ancestors), Referrer-Policy and Permissions-Policy cover the common browser-side risks.
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;A location that defines any add_header discards every header inherited from the server block. Repeat the full set in that location, or define headers in an include.
Open the Security headers generator
No. It is obsolete and can introduce issues; rely on a Content-Security-Policy instead.