Welcome! Log In Create A New Profile

Advanced

Re: Using add_header at server level context

Francis Daly
September 30, 2013 10:32AM
On Mon, Sep 30, 2013 at 03:42:50PM +0200, Thijs Koerselman wrote:

Hi there,

> From the add_header docs I understand that it works at location, http and
> server context. But when I use add_header at the server level I don't see
> the headers being added to the response.

> Am I missing something or is this just not working at the server level for
> some reason?

You're missing something.

You're either missing that if the second argument to add_header expands
to empty, then the header is not added; or that configuration directive
inheritance is by replacement, not addition.

==
server {
listen 8080;
add_header X-Server server-level;
add_header X-Surprise $http_surprise;

location /one {
return 200 "location one";
}
location /two {
return 200 "location two";
add_header X-Location two;
}
}
==

Compare the outputs you actually get from

curl -i http://127.0.0.1:8080/one

curl -i http://127.0.0.1:8080/two

curl -i -H Surprise:value http://127.0.0.1:8080/one

with what you expect to get.

f
--
Francis Daly francis@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Using add_header at server level context

Thijs Koerselman September 30, 2013 09:44AM

Re: Using add_header at server level context

Francis Daly September 30, 2013 10:32AM

Re: Using add_header at server level context

Thijs Koerselman October 07, 2013 10:04AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 158
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