Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@arut
Copy link
Contributor

@arut arut commented Oct 6, 2025

New directives add_header_inherit and add_trailer_inherit control how headers and trailers are inherited from the previous level.

The value off disables inheritance. The value on (default) triggers the previous behavior when the values from the previous level are inherited only if no values are set at the current level. The value merge enables merging the values from the previous level into the current level values.

The inheritance control modes are themselves inherited in a standard way. Thus add_header_inherit merge specified at the top level will enable the merge inheritance mode for all the levels below.

Inheritance control for other directives like proxy_set_header may follow later.

This addresses #591

@github-actions
Copy link

github-actions bot commented Oct 6, 2025

✅ All required contributors have signed the F5 CLA for this PR. Thank you!
Posted by the CLA Assistant Lite bot.

@arut
Copy link
Contributor Author

arut commented Oct 6, 2025

I have hereby read the F5 CLA and agree to its terms

@arut arut requested a review from pluknet October 6, 2025 16:28
@pluknet
Copy link
Contributor

pluknet commented Oct 13, 2025

Inheritance control for add_header and add_trailer.

Headers filter: ?

New directives add_header_inherit and add_trailer_inherit control how
headers and trailers are inherited from the previous level.

The value "off" disables inheritance. The value "on" (default) triggers

s/value/parameter/? also to avoid confusing with header/trailer array "values"

the previous behavior when the values from the previous level are inherited
only if no values are set at the current level.

Just for the record, both can be expressed with add_header "" (empty value).
So essentially this adds a syntax sugar value by the "merge" mode.

The value "merge" enables
merging the values from the previous level into the current level values.

The inheritance control modes are themselves inherited in a standard way.
Thus "add_header_inherit merge" specified at the top level will enable
the merge inheritance mode for all the levels below.

Personally, it may be visually challenging to read text not broken in paragraphs,
I'd add some empty lines for better visibility experience.

Headers filter: inheritance control for add_header and add_trailer.

The new directives add_header_inherit and add_trailer_inherit allow
to alter inheritance rules for the values specified in the add_header
and add_trailer directives in a convenient way.

The "merge" parameter appends the values from the previous level to
the current level values.

The "off" parameter cancels inheritance of the values from the previous
configuration level, similar to add_header "" (2194e75bb).

The "on" parameter restores the default behaviour to inherit values from
the previous level only if there are no directives on the current level.

The inheritance rules themselves are inherited in a standard way.  Thus,
for example, "add_header_inherit merge;" specified at the top level will
be inherited in all nested levels recursively unless redefined below.

@pluknet
Copy link
Contributor

pluknet commented Oct 13, 2025

The diff technically looks good, though I'd still try to implement this in the existing directives,
similar to proxy_redirect off;. This would also match expires off; in the same module.

@Maryna-f5 Maryna-f5 added this to the nginx-1.29.3 milestone Oct 20, 2025
The new directives add_header_inherit and add_trailer_inherit allow
to alter inheritance rules for the values specified in the add_header
and add_trailer directives in a convenient way.

The "merge" parameter enables appending the values from the previous level
to the current level values.

The "off" parameter cancels inheritance of the values from the previous
configuration level, similar to add_header "" (2194e75).

The "on" parameter (default) enables the standard inheritance behaviour,
which is to inherit values from the previous level only if there are no
directives on the current level.

The inheritance rules themselves are inherited in a standard way.  Thus,
for example, "add_header_inherit merge;" specified at the top level will
be inherited in all nested levels recursively unless redefined below.
@arut
Copy link
Contributor Author

arut commented Oct 23, 2025

The diff technically looks good, though I'd still try to implement this in the existing directives, similar to proxy_redirect off;. This would also match expires off; in the same module.

Discussed this in person. My points:

  • embedding inheritance control into add_header will make it hard to implement similar behavior for other directives (proxy_set_header for example)
  • it's not clear how embedded inheritance control will itself be inherited, while a separate directive is inherited in a standard way

@arut
Copy link
Contributor Author

arut commented Oct 23, 2025

Inheritance control for add_header and add_trailer.

Headers filter: ?

New directives add_header_inherit and add_trailer_inherit control how
headers and trailers are inherited from the previous level.
The value "off" disables inheritance. The value "on" (default) triggers

s/value/parameter/? also to avoid confusing with header/trailer array "values"

the previous behavior when the values from the previous level are inherited
only if no values are set at the current level.

Just for the record, both can be expressed with add_header "" (empty value). So essentially this adds a syntax sugar value by the "merge" mode.

The value "merge" enables
merging the values from the previous level into the current level values.
The inheritance control modes are themselves inherited in a standard way.
Thus "add_header_inherit merge" specified at the top level will enable
the merge inheritance mode for all the levels below.

Personally, it may be visually challenging to read text not broken in paragraphs, I'd add some empty lines for better visibility experience.

Headers filter: inheritance control for add_header and add_trailer.

The new directives add_header_inherit and add_trailer_inherit allow
to alter inheritance rules for the values specified in the add_header
and add_trailer directives in a convenient way.

The "merge" parameter appends the values from the previous level to
the current level values.

The "off" parameter cancels inheritance of the values from the previous
configuration level, similar to add_header "" (2194e75bb).

The "on" parameter restores the default behaviour to inherit values from
the previous level only if there are no directives on the current level.

The inheritance rules themselves are inherited in a standard way.  Thus,
for example, "add_header_inherit merge;" specified at the top level will
be inherited in all nested levels recursively unless redefined below.

Thanks, modified a bit and applied.

@arut arut force-pushed the add-header-inherit branch from 7ffec80 to 3315d28 Compare October 23, 2025 15:06
Copy link
Contributor

@pluknet pluknet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome.

@arut arut merged commit c93a0c4 into nginx:master Oct 25, 2025
2 checks passed
@arut arut deleted the add-header-inherit branch October 25, 2025 15:46
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.

3 participants