Override a set_empty variable from http params
Quintin Par
quintinpar at gmail.com
Wed Oct 17 04:05:21 UTC 2012
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;
On Mon, Oct 15, 2012 at 1:35 PM, Igor Sysoev <igor at sysoev.ru> wrote:
> 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 at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20121017/e8ab1903/attachment.html>
More information about the nginx
mailing list