Multiple add_header


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
location is used.
If I remove the add_header in the location block, I get the header I
in the server block.

Here’s a short example:
server {
add_header Strict-Transport-Security “max-age=604800;

location = /blah {
add_header X-Test test;

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

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

Seems is the same problem.

Best Regards

Posted at Nginx Forum:,260102,260102#msg-260102


there is no chance to avoid the duplicates. I asked the same questions
time ago.
For detailed answer on my question see,256270,256279#msg-256279.

I think this will answer your question too.

Best Regards

Posted at Nginx Forum:,260102,260103#msg-260103

Hello okamzol and thanks a lot for your answer!

Yes, it’s exactly the same question, looks like I’ll need to use

Best Regards

Posted at Nginx Forum:,260102,260104#msg-260104

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs