Welcome! Log In Create A New Profile

Advanced

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

February 05, 2014 01:49AM
I am seeing strange behavior using includes. For example, if I request a javascript file (ending in .js) the headers set globally in the server block are not set. I was under the impression that if you set headers in the server block, ALL location blocks below inherit those headers.

See the following:

server {
...
add_header Strict-Transport-Security max-age=31556926;
add_header X-XSS-Protection "1; mode=block";
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;

include expires.conf;
...
}


# expires.conf
location ~* \.(?:ico|js|css|gif|jpe?g|png|xml)$ {
expires 7d;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}

When requesting a .js file, the Pragma and Cache-Control headers are set, but all the headers set in the base server block are not. What is the fix here?
Subject Author Posted

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

justink101 February 05, 2014 01:49AM

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

Francis Daly February 05, 2014 08:34AM

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

Maxim Dounin February 05, 2014 08:54AM

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

Francis Daly February 05, 2014 10:12AM

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

Maxim Dounin February 05, 2014 11:44AM

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

justink101 February 05, 2014 10:55AM

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

itpp2012 February 05, 2014 01:51PM

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

Francis Daly February 05, 2014 07:52PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 75
Record Number of Users: 5 on July 11, 2016
Record Number of Guests: 271 on July 19, 2016
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready