Welcome! Log In Create A New Profile

Advanced

Re: Override a set_empty variable from http params

October 15, 2012 04:06AM
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

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Override a set_empty variable from http params

Quintin Par October 14, 2012 02:32PM

Re: Override a set_empty variable from http params

Igor Sysoev October 15, 2012 04:06AM

Re: Override a set_empty variable from http params

Quintin Par October 17, 2012 12:06AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 304
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready