geoip_country_code header is deleted when I set another custom header

Ruslan Ermilov ru at nginx.com
Fri Jan 10 10:37:56 UTC 2014


On Fri, Jan 10, 2014 at 04:40:00AM -0500, MarcPapers wrote:
[...]
> location / {
>                 proxy_pass http://xx;
>                 access_log  /var/log/nginx/xx.access.log menosbasico;
>                 proxy_set_header ismobiletraffic $mobile_flag;
>         }
> 
> ## END DEFAULT FILE ##
> 
> The proxy_set_header directive for geoip is placed in nginx.conf
> 
> ## BEGIN NGINX.CONF ##
> 
> ...
> ...
> 
> http {
>     access_log /var/log/nginx/access.log;
>     error_log /var/log/nginx/error.log;
>     rewrite_log on;
> 
>     proxy_set_header X-Forwarded-For $remote_addr;
> 
>     geoip_country  /usr/share/GeoIP/GeoIP.dat;
>     proxy_set_header GEOIP_COUNTRY_CODE $geoip_country_code;
> 
> ...
> ...
> 
> ## END NGINX.CONF ##
> 
> The problem is that now, the ismobiletraffic header is set correctly, but
> the geoip headers have disspeared from the request. Seems to have been
> overwritten. Should I place the mobile traffic detection on NGINX.CONF at
> http{ } level? I have been looking for a solution but I didn't find anything
> helpful. Thanks in advance for your tips and advices!

It's expected and documented behavior: http://nginx.org/r/proxy_set_header

: These directives are inherited from the previous level if and only if
: there are no proxy_set_header directives defined on the current level.



More information about the nginx mailing list