path-based reverse proxy

Igor Sysoev igor at sysoev.ru
Mon Sep 6 17:10:46 MSD 2010


On Sun, Sep 05, 2010 at 12:28:44PM -0700, UnclePhil wrote:

> Try with the location  in reverse orde ;
> More specific first, root at last position
> 
> I had a similar problem and this was solving it

If you use locations without regexes, the order has no meaning.

> Unclephil
> 
> On Sep 4, 11:25 am, "cantabile" <nginx-fo... at nginx.us> wrote:
> > Hi all,
> >
> > I'm new to nginx and I'm looking for a path-based reverse-proxy.
> > Here's my setup.
> >
> > nginx server has $PUB_IP, listening to port 80
> > I have two webservers with $IP1 and $IP2
> >
> > I want to access my main server from a browser with http://$PUB_IP and
> > the second server with http://$PUB_IP/myapp
> >
> > I can't find how to do it.
> >
> > I tried defining two servers in sites-available, default and myapp, but
> > since they listen on the same port, I always have the same server with
> > both http://$pub_ip and http://$pub_ip/myapp. Seems logical to me since
> > nothing can tell nginx wich server it was supposed to redirect to.
> >
> > I have tried to put another location in site-available/default, like
> > this
> >
> > server {
> > ...
> > location / {
> >            proxy_pass http://$IP1
> >            }
> >
> > location /myapp {
> >            proxy_pass http://$IP2
> >            }
> >
> > }
> >
> > But that doesn't  work. I can only have the main page of site2, not even
> > the images in the same directoriy. And by the way that looks wrong,
> > 'cause site2 isn't another directory of site1, it's another
> > webserver...
> >
> > So could somebody give me an example or a little help with that ?
> >
> > Thx a lot !
> >
> > PS : I have no access to the dns. I can't play with the names likewww.site1.comandwww.site2.com
> >
> > Posted at Nginx Forum:http://forum.nginx.org/read.php?2,127024,127024#msg-127024
> >
> > _______________________________________________
> > nginx mailing list
> > ng... at nginx.orghttp://nginx.org/mailman/listinfo/nginx
> 
> 
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://nginx.org/mailman/listinfo/nginx

-- 
Igor Sysoev
http://sysoev.ru/en/



More information about the nginx mailing list