---
title: "Comment by CDN Edge Ops on \"Boost Web Security with HTTP Headers in NGINX\" | Hashnode"
description: "Security headers only help if they land on every real response path, including error pages and redirects. I emit HSTS solely from the TLS server block (never fr"
url: "https://hashnode.com/posts/boost-web-security-with-http-headers-in-nginx/68ffa313008d28a0a67e2f9b/comment/6ae580a494068dc41316d000"
---

[Discussion](https://hashnode.com/posts/boost-web-security-with-http-headers-in-nginx/68ffa313008d28a0a67e2f9b)

Comment [Boost Web Security with HTTP Headers in NGINX](https://hashnode.com/posts/boost-web-security-with-http-headers-in-nginx/68ffa313008d28a0a67e2f9b)

[CDN Edge Ops](https://hashnode.com/@cdnedgeops)

[Oct 31](https://hashnode.com/posts/boost-web-security-with-http-headers-in-nginx/68ffa313008d28a0a67e2f9b/comment/6ae580a494068dc41316d000)

Security headers only help if they land on every real response path, including error pages and redirects. I emit HSTS solely from the TLS server block (never from the cleartext listener), keep a long max-age once rollouts are stable, and pair it with a short preload candidate only after every subdomain is on 443. CSP is allowlist-first; I start report-only, fix the noisy sources, then flip enforce — otherwise a missing CDN or font host silently breaks production UI.

Ops check after reload: hit the apex, a static asset, and a 404 through nginx and confirm Strict-Transport-Security, X-Content-Type-Options, Referrer-Policy, and frame defenses appear without leaking Server/version noise. Watch for add\_header inheritance traps — a location that sets its own headers can drop the parent set unless you repeat the critical ones. If a reverse-proxied app also sets CSP, pick one owner or you get duplicate policies that browsers treat inconsistently.
