Skip to content

fix(nginx): add security headers to static assets location block#196

Open
andrerfneves wants to merge 1 commit into
mainfrom
maintenance/fix-nginx-security-headers-static-20260619
Open

fix(nginx): add security headers to static assets location block#196
andrerfneves wants to merge 1 commit into
mainfrom
maintenance/fix-nginx-security-headers-static-20260619

Conversation

@andrerfneves

Copy link
Copy Markdown
Owner

Summary

In nginx, add_header directives at the server level are NOT inherited by a location block that defines its own add_header. The static assets location block set add_header Cache-Control "public, immutable", which prevented server-level security headers from being applied to cached static assets.

Why

Without this fix, cached static assets (JS, CSS, fonts, images) served via the static assets location block would not receive:

  • X-Frame-Options
  • X-Content-Type-Options
  • X-XSS-Protection
  • Referrer-Policy

While these assets are served same-origin, consistent security headers across all responses follow security best practices and are important when assets are served through CDNs or reverse proxies.

Changes

  • nginx.conf: Added the four security headers to the static assets location block so they are applied regardless of which location processes the request

Test Plan

  • Nginx config syntax is valid (no structural changes)
  • All 52 existing tests pass
  • No behavior change for non-static-asset routes (server-level headers still cover location /)
  • Existing Docker deployment pattern continues to work unchanged

In nginx, add_header directives are NOT inherited from the
server level to a location block that defines its own add_header.
The static assets location block set add_header Cache-Control,
which prevented server-level security headers (X-Frame-Options,
X-Content-Type-Options, X-XSS-Protection, Referrer-Policy) from
being applied to cached static assets.

This fix duplicates the security headers inside the static assets
location block so that all responses receive consistent headers
regardless of which location block processes them.
@vercel

vercel Bot commented Jun 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lightning-decoder Ready Ready Preview, Comment Jun 19, 2026 10:05am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant