Welcome! Log In Create A New Profile

Advanced

Multiple add_header

Alt
July 06, 2015 06:20PM
Hello,

I'm using PHP with nginx 1.9.2 and it works great!
But there's something I don't understand with the add_header directive.

I use add_header in server and location block, but it seems only the one in location is used.
If I remove the add_header in the location block, I get the header I added in the server block.

Here's a short example:
server {
add_header Strict-Transport-Security "max-age=604800; includeSubDomains";

location = /blah {
add_header X-Test test;
}
}

If I access /blah, I'll only get the X-Test header, while I'd like to get X-Test and Strict-Transport-Security.
If I comment the add_header in the blah location and access /blah, I'll get the Strict-Transport-Security header.

How can I solve this problem, without having to duplicate/include "add_header Strict-Transport-Security" everywhere?

Seems http://stackoverflow.com/a/19135714 is the same problem.

Best Regards
Subject Author Posted

Multiple add_header

Alt July 06, 2015 06:20PM

Re: Multiple add_header

okamzol July 06, 2015 06:41PM

Re: Multiple add_header

Alt July 06, 2015 06:55PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 300
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready