nginx config_error ai_generated true

add_header directive not inherited in nested location

ID: nginx/add-header-not-inherited

Also available as: JSON · Markdown
82%Fix Rate
86%Confidence
3Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1 active

Root Cause

add_header directives in parent block not inherited when child has own add_header.

generic

Workarounds

  1. 90% success Use ngx_headers_more module: more_set_headers always inherits
  2. 85% success Include shared header file in each location block

Dead Ends

Common approaches that don't work:

  1. Duplicate all headers in every location block 72% fail

    Maintenance nightmare

  2. Use server-wide headers only 68% fail

    Loses per-location customization