Reverse proxy for multiple websites

Maxim Dounin mdounin at mdounin.ru
Mon Jan 2 23:59:05 UTC 2012


Hello!

On Mon, Jan 02, 2012 at 12:10:59PM +0700, Nguyen Hai Nam wrote:

> Hi,
> 
> I'm sticking on configure a reverse proxy, my scenario looks like:
> 
> Internet
> .......|
> .......|__Reverse proxy (listen port 80)
> ......................|__web1.com (listen port 8080)
> ......................|__web2.net (listen port 8080)
> ......................|__web-n.org (listen port 8080)
> 
> Assume All website shared one public IP only and each website runs on
> independent VPS.
> 
> If I create multi server{} block to use proxy_pass directive to web
> server inside, it's only web1.com can be reachable (perhaps it's on
> top config).
> 
> It's highly appreciate if someone advice me ideas to make this working.

If many backend sites share the same ip, and you refer all of them 
with the same name (or ip) in proxy_pass directive, you probably 
want to use somethine like

    proxy_set_header Host <name>;

to make sure backend will be able to distinguish them.  Or just

    proxy_set_header Host $host;

to pass what you've got from client.

Maxim Dounin



More information about the nginx mailing list