# Reverse proxy for multiple websites

**URL:** <https://www.ruby-forum.com/t/reverse-proxy-for-multiple-websites/215371>\
**Category:** NGINX\
**Created:** [January 2, 2012, 6:11am UTC](https://www.ruby-forum.com/t/reverse-proxy-for-multiple-websites/215371 "2012-01-02T06:11:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [January 2, 2012, 6:11am UTC](https://www.ruby-forum.com/t/reverse-proxy-for-multiple-websites/215371/1 "2012-01-02T06:11:31Z")

</div>

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](http://web1.com) can be reachable (perhaps it’s on  
top config).

It’s highly appreciate if someone advice me ideas to make this working.

Thanks,

–  
Best regards,  
Hai N., Nguyen

---

<div class="post-metadata">

**Author:** ![nhatbk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ed655f/32.png) [@nhatbk](https://www.ruby-forum.com/u/nhatbk)\
**Post date:** [January 3, 2012, 12:59am UTC](https://www.ruby-forum.com/t/reverse-proxy-for-multiple-websites/215371/2 "2012-01-03T00:59:24Z")

</div>

Hello!

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

> 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](http://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 D.

---

<div class="post-metadata">

**Author:** ![nhatbk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ed655f/32.png) [@nhatbk](https://www.ruby-forum.com/u/nhatbk)\
**Post date:** [January 16, 2012, 7:14am UTC](https://www.ruby-forum.com/t/reverse-proxy-for-multiple-websites/215371/3 "2012-01-16T07:14:42Z")

</div>

hi,  
Can u show ur configuration?

Dev

Posted at Nginx Forum:

> **[Re: Reverse proxy for multiple websites](https://forum.nginx.org/read.php?2,220736,221282#msg-221282)**
>
> 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) ....

---

<div class="post-metadata">

**Author:** ![nhatbk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ed655f/32.png) [@nhatbk](https://www.ruby-forum.com/u/nhatbk)\
**Post date:** [January 19, 2012, 2:43am UTC](https://www.ruby-forum.com/t/reverse-proxy-for-multiple-websites/215371/4 "2012-01-19T02:43:48Z")

</div>

## dev Wrote:

> hi,  
> Can u show ur configuration?
> 
> Dev

Hi Dev,

I’ve followed this document

> **[How nginx processes a request](http://nginx.org/en/docs/http/request_processing.html)**

And I think my problem was missing deffinitions for “www.domain.tld” in  
server\_name; after edit it to

server\_name domain.tld www.domain.tld;

the problem solved.

Thanks for your attention.  
~Neddy

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,220736,221415#msg-221415](http://forum.nginx.org/read.php?2,220736,221415#msg-221415)
