Other headers disappear after adding Set-Cookie header
    Maxim Dounin 
    mdounin at mdounin.ru
       
    Mon Aug 16 18:29:31 MSD 2010
    
    
  
Hello!
On Mon, Aug 16, 2010 at 09:22:07AM -0400, Unimatrix02 wrote:
[...]
> 
> 		# 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=/;
> domain=.ibood.com;";
> 			}
> 		
> 			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.
    location ... {
        add_header X-DebugInfo ...
        add_header X-Info ...
        if (...) {
            add_header Set-Cookie ...
            add_header X-DebugInfo ...
            add_header X-Info ...
        }
    }
Further reading:
http://wiki.nginx.org/IfIsEvil
[...]
> [b]debug log[/b]
> 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"
This isn't a debug log as you haven't recompiled nginx with 
--with-debug option.  Doesn't matter though, problem is clear from 
the config itself.
Maxim Dounin
    
    
More information about the nginx
mailing list