Are headers set in the server block inherited to all location blocks

Maxim Dounin mdounin at mdounin.ru
Wed Feb 5 13:52:21 UTC 2014


Hello!

On Wed, Feb 05, 2014 at 01:33:34PM +0000, Francis Daly wrote:

> On Wed, Feb 05, 2014 at 01:49:59AM -0500, justink101 wrote:
> 
> Hi there,
> 
> > I was under the impression that if you set headers in the
> > server block, ALL location blocks below inherit those headers.
> 
> No.
> 
> Can you say where you got that impression? Perhaps documentation can be
> clarified or corrected.

It looks like add_header documentation doesn't have our usual 
clause for array-like directives, and something like this should 
be helpful:

--- a/xml/en/docs/http/ngx_http_headers_module.xml
+++ b/xml/en/docs/http/ngx_http_headers_module.xml
@@ -56,6 +56,14 @@ the response code equals 200, 201, 204, 
 A value can contain variables.
 </para>
 
+<para>
+There could be several <literal>add_header</literal> directives.
+These directives are inherited from the previous level if and
+only if there are no
+<literal>add_header</literal>
+directives defined on the current level.
+</para>
+
 </directive>
 
-- 
Maxim Dounin
http://nginx.org/



More information about the nginx mailing list