Explains why a security scan keeps flagging HSTS after you add the header, which response the scanner actually inspects, and the correct configuration for IIS, ASP.NET Core, Nginx, Apache, Next.js and Cloudflare. Redirect hops and scheme detection behind a proxy are the two most common traps.
Key points
- Scan reports do not follow redirects: the www or apex redirect response must carry `Strict-Transport-Security` itself.
- `AddHsts()` in ASP.NET Core defaults to a 30-day `MaxAge`; use `TimeSpan.FromDays(365)` for a full year.
- `UseHsts()` only adds the header on requests it sees as HTTPS, so `UseForwardedHeaders()` is required behind a TLS-terminating proxy.
- In Nginx, any `add_header` inside a `location` block drops all inherited headers, silently losing HSTS for that path.
- `includeSubDomains` and `preload` are not needed to clear the finding and can lock users out for the whole max-age.
- Nessus plugin 142960 shipped false-positive tuning in mid-2026 and changed NTLM challenge handling in October 2026.
Real-world use
- Setups that terminate TLS at Cloudflare or a load balancer and need the ASP.NET Core app to see the original scheme
- Sites that skip `includeSubDomains` because admin panels and webmail still answer on plain HTTP
- Nginx configurations that must keep HSTS while adding a cache header to one specific location
This summary was generated by the agent from the original post on DEV Community: #dotnet. The full text and all rights belong to its author and publisher. Go to original