Override a set_empty variable from http params
Igor Sysoev
igor at sysoev.ru
Mon Oct 15 08:05:45 UTC 2012
On Sun, Oct 14, 2012 at 11:30:22AM -0700, Quintin Par wrote:
> Hi all,
>
> I set the some params to my backend server as shown below
>
> set_if_empty $country_code $http_x_country_code;
>
> proxy_set_header X-Country-Code $country_code;
>
> Now the http_x_country_code comes via the GeoIP module.
>
> Is there a way here I can override this based on an HTTP param I can set.
>
> Say site.com/country=US and country variable has greater precedence over
> the http_x_country_code.
Using "map" you can define:
http {
map $arg_country $country_code {
"" $header_country;
default $arg_country;
}
map $http_x_country_code $header_country {
"" $geoip_country_code;
default $http_x_country_code;
}
...
location / {
proxy_set_header X-Country-Code $country_code;
...
--
Igor Sysoev
http://nginx.com/support.html
More information about the nginx
mailing list