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 2012-10-14 20:31
on 2012-10-15 10:06
On Sun, Oct 14, 2012 at 11:30:22AM -0700, Quintin Par 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 Sysoev http://nginx.com/support.html
on 2012-10-17 06:05
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;
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.