aris
1
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.
On Sun, Oct 14, 2012 at 11:30:22AM -0700, Quintin P. wrote:
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 S.
Igor,
Is this correct?
set $country_code $arg_country;
set_if_empty $country_code $geoip_country_code;
proxy_set_header X-Country-Code $country_code;