In a configuration with several locations, I am using
add_header Set-Cookie “name=value; domain=xyz.com; path=/”;
and some other headers, like
add_header X-Info “Some information”
When the Set-Cookie header is added, all additional headers suddenly
disappear. When the Set-Cookie add_header call is disabled, the
additional headers appear as normal.
First I thought it might be a bug, but this behavior doesn’t occur when
I put this combination of headers in another location in another
(simpler) server block. I also upgraded from 0.7.67 to 0.8.49 to see if
that would make a difference, but it still happens.
Apparently there is something that drops the additional headers, but I
have no idea what. I have disabled all other locations, disabled all
other things (like expires), but without any effect.
The server block in which this happens is build up as follows:
Capture of a variable from the URL;
Rewrite of certain URLs to a static HTML page;
Location to serve the static HTML pages, which includes the add_header
call for Set-Cookie, to pass on the value from the captured variable in
a cookie;
Location to serve other static content (css, images, etc);
Location to proxy to apache.
I hope someone knows why this happens, and if it should be considered a
bug or not.
server
{
listen 80 default backlog=1024;
server_name _;
server_name_in_redirect off;
# Look for affiliate in URI
set $aff_id "";
if ($request_uri ~* "(affiliate,|affiliate=)([a-z0-9]*)")
{
set $aff_id $2;
}
# Redirect old NL variants to main NL variant
rewrite ^/(depers|ad|iex|nu)/nl(.*)$ /nl/nl$2 permanent;
# Redirect banners to ext
rewrite ^/(banners/.*)$ http://ext.ibood.com/$1 permanent;
# Redirect feed requests to ext.ibood.com
rewrite ^/feeds/ibood_([^_/]+)_([^_/]+)\.xml$
# Redirect to splash page if request uri is still /
rewrite ^/$ /index.html last;
# ----
# Serve generated HTML files directly, but expire immediately
location ~ /static/generated/.*\.html$
{
# Set cookie with affiliate ID, if present
if ($aff_id != "")
{
add_header Set-Cookie "iboodaffiliates=$aff_id; path=/;
debug log
2010/08/16 15:12:22 [notice] 24579#0: 1
"(affiliate,|affiliate=)([a-z0-9])" matches
“/nl/nl/index/affiliate,Affilinet/”, client: 192.168.32.50, server: ,
request: “GET /nl/nl/index/affiliate,Affilinet/ HTTP/1.1”, host:
“r.dev.ibood.com”
2010/08/16 15:12:22 [notice] 24579#0: 1 "^/(depers|ad|iex|nu)/nl(.)$"
does not match “/nl/nl/index/affiliate,Affilinet/”, client:
192.168.32.50, server: , request: “GET
/nl/nl/index/affiliate,Affilinet/ HTTP/1.1”, host: “r.dev.ibood.com”
2010/08/16 15:12:22 [notice] 24579#0: 1 "^/(banners/.)$" does not
match “/nl/nl/index/affiliate,Affilinet/”, client: 192.168.32.50,
server: , request: “GET /nl/nl/index/affiliate,Affilinet/ HTTP/1.1”,
host: “r.dev.ibood.com”
2010/08/16 15:12:22 [notice] 24579#0: *1
"^/feeds/ibood([^/]+)([^_/]+).xml$" does not match
“/nl/nl/index/affiliate,Affilinet/”, client: 192.168.32.50, server: _,
request: “GET /nl/nl/index/affiliate,Affilinet/ HTTP/1.1”, host:
“r.dev.ibood.com”
2010/08/16 15:12:22 [notice] 24579#0: 1 "^/feeds/(.)$" does not match
“/nl/nl/index/affiliate,Affilinet/”, client: 192.168.32.50, server: _,
request: “GET /nl/nl/index/affiliate,Affilinet/ HTTP/1.1”, host:
“r.dev.ibood.com”
2010/08/16 15:12:22 [notice] 24579#0: 1 "^(/cms/.)$" does not match
“/nl/nl/index/affiliate,Affilinet/”, client: 192.168.32.50, server: _,
request: “GET /nl/nl/index/affiliate,Affilinet/ HTTP/1.1”, host:
“r.dev.ibood.com”
2010/08/16 15:12:22 [notice] 24579#0: 1
"^([^.])/imgdesign/([^.]).([^.])$" does not match
“/nl/nl/index/affiliate,Affilinet/”, client: 192.168.32.50, server: _,
request: “GET /nl/nl/index/affiliate,Affilinet/ HTTP/1.1”, host:
“r.dev.ibood.com”
2010/08/16 15:12:22 [notice] 24579#0: 1 "^([^.])/style/(.).css$"
does not match “/nl/nl/index/affiliate,Affilinet/”, client:
192.168.32.50, server: _, request: “GET
/nl/nl/index/affiliate,Affilinet/ HTTP/1.1”, host: “r.dev.ibood.com”
2010/08/16 15:12:22 [notice] 24579#0: 1 "^([^.])/js/(.).js$" does
not match “/nl/nl/index/affiliate,Affilinet/”, client: 192.168.32.50,
server: _, request: “GET /nl/nl/index/affiliate,Affilinet/ HTTP/1.1”,
host: “r.dev.ibood.com”
2010/08/16 15:12:22 [notice] 24579#0: 1
"^/img/(.).(swf|js|ico|gif|jpg|JPG|png|css)$" does not match
“/nl/nl/index/affiliate,Affilinet/”, client: 192.168.32.50, server: _,
request: “GET /nl/nl/index/affiliate,Affilinet/ HTTP/1.1”, host:
“r.dev.ibood.com”
2010/08/16 15:12:22 [notice] 24579#0: 1
"^/templates_dynamic/(.).(js|ico|gif|jpg|JPG|png|css)$" does not match
“/nl/nl/index/affiliate,Affilinet/”, client: 192.168.32.50, server: _,
request: “GET /nl/nl/index/affiliate,Affilinet/ HTTP/1.1”, host:
“r.dev.ibood.com”
2010/08/16 15:12:22 [notice] 24579#0: *1 “^(.+).html/?$” does not match
“/nl/nl/index/affiliate,Affilinet/”, client: 192.168.32.50, server: _,
request: “GET /nl/nl/index/affiliate,Affilinet/ HTTP/1.1”, host:
“r.dev.ibood.com”
2010/08/16 15:12:22 [notice] 24579#0: 1
"^/(pl/pl|nl/nl|de/de|uk/en|be/nl|ie/en|bild/de)/(product_specs/.)$"
does not match “/nl/nl/index/affiliate,Affilinet/”, client:
192.168.32.50, server: _, request: “GET
/nl/nl/index/affiliate,Affilinet/ HTTP/1.1”, host: “r.dev.ibood.com”
2010/08/16 15:12:22 [notice] 24579#0: *1
“^/(pl/pl|nl/nl|de/de|uk/en|be/nl|ie/en|bild/de)(/?)$” does not match
“/nl/nl/index/affiliate,Affilinet/”, client: 192.168.32.50, server: _,
request: “GET /nl/nl/index/affiliate,Affilinet/ HTTP/1.1”, host:
“r.dev.ibood.com”
2010/08/16 15:12:22 [notice] 24579#0: 1
"^/(pl/pl|nl/nl|de/de|uk/en|be/nl|ie/en|bild/de)/index." matches
“/nl/nl/index/affiliate,Affilinet/”, client: 192.168.32.50, server: _,
request: “GET /nl/nl/index/affiliate,Affilinet/ HTTP/1.1”, host:
“r.dev.ibood.com”
2010/08/16 15:12:22 [notice] 24579#0: *1 rewritten data:
“/static/generated/nl/nl/index.html”, args: “”, client: 192.168.32.50,
server: _, request: “GET /nl/nl/index/affiliate,Affilinet/ HTTP/1.1”,
host: “r.dev.ibood.com”
I hope this helps to figure it out. My idea is that it has something to
do with the placement of the add_header call in a specific location
block but I haven’t been able to reproduce this problem with a simpler
server block.
On Mon, Aug 16, 2010 at 09:22:07AM -0400, Unimatrix02 wrote:
[…]
add_header X-DebugInfo aff_id=$aff_id;
add_header X-Info "Served by nginx 1:$uri";
This code defines two locations. One of them has add_header array
set to “X-DebugInfo, X-Info” and another one (implicitly defined
by “if”) has it redefined to “Set-Cookie”.
You have to duplicate other add_header directives within implicit
location defined by “if”, i.e.