multiple proxy_pass

J Davis mrsalty0 at gmail.com
Tue Aug 5 17:29:17 MSD 2008


Perfect. Thank you!


On Mon, Aug 4, 2008 at 12:02 PM, Igor Sysoev <is at rambler-co.ru> wrote:

> On Mon, Aug 04, 2008 at 09:27:34AM -0400, J Davis wrote:
>
> > Turns out my if statment just neede a "break;"...
> > .
> > if ($host = 'secondary.example.com') {
> >     proxy_pass http://secondary;
> >     break;
> > }
>
> Actually, you need two servers:
>
>    server {
>          server_name primary.example.com;
>          location / {
>              proxy_pass http://primary;
>               proxy_set_header Host $http_host;
>         }
>    }
>
>     server {
>          server_name secondary.example.com;
>
>          location / {
>               proxy_pass http://secondary;
>              proxy_set_header Host $http_host;
>          }
>    }
>
>
> > Thanks.
> > -Jake
> >
> > On Sun, Aug 3, 2008 at 4:37 PM, J Davis <mrsalty0 at gmail.com> wrote:
> >
> > > Should it be possible to use a different proxy_pass statement under a
> > > single location using if statement?
> > > I've tried using the following config but all traffic gets passed to
> the
> > > 'primary' upstream regardless of the value of $host.
> > >
> > > upstream primary {
> > >         server x.x.x.x;
> > >     }
> > >
> > > upstream secondary {
> > >         server x.x.x.x;
> > >     }
> > >
> > > location / {
> > >             if ($host = 'secondary.example.com') {
> > >                 proxy_pass http://secondary;
> > >             }
> > >             proxy_set_header Host $http_host;
> > >             proxy_pass http://primary;
> > >         }
> > >
> > > Many thanks,
> > > -Jake
> > >
>
> --
> Igor Sysoev
> http://sysoev.ru/en/
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20080805/891b1ba8/attachment.html>


More information about the nginx mailing list