Location directive not working

Alex alex.thegreat at ambix.net
Wed Mar 26 00:30:21 UTC 2014

I set up two upstream servers (server 1 and server 2) where I geotarget
people from specific countries: A

People from country A go to server 1 and the others go to server 2.

There are some uri s that must be served by server 1 when the person is in
country A. So I have created this directive.  It works only when I include
one item, when I do (videos|events) it does not work

location ^~ /(videos|events) {
  proxy_pass http://$server1$request_uri;
  proxy_set_header        Host            $host;
  proxy_set_header        X-Real-IP       $remote_addr;
  proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;


I do it this way because there are URLs that contain videos and events
that must be served by server 1.  For example,
domain.com/videos/playing-with-my-dog etc.  When I reload this directive
nginx does not give me any errors, but when I try to access it from
country B, it does not work.

Thanks for all your help!


More information about the nginx mailing list