1

My setup is basically this: I have pointed two domains at my VPS running Ubuntu 10.04. I am using an nginx frontend and Apache running Django with mod-wsgi (not an issue, it works fine).

Nginx is proxying just fine and Apache does its job, but all requests are picked up by the first Virtualhost, even if the server_name is not supposed to match. So domain1.com and domain2.com are both giving me the same webpage. Grateful for any ideas/answers! If anything needs to be clarified, please let me know.

nginx server conf

server {
     listen  80  default;
     server_name domain1.com;

     location / {
         proxy_pass http://localhost:8001;
         proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

server {
     listen  80;
     server_name domain2.com;

     location / {
         proxy_pass http://localhost:8001;
         proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

And the Apache conf:

NameVirtualHost *:8001

<VirtualHost *:8001>
    ServerAdmin webmaster@localhost
    ServerName domain1.com
    ServerAlias www.domain1.com
    ...
</VirtualHost>

<VirtualHost *:8001>
    ServerAdmin webmaster@localhost
    ServerName domain2.com
    ServerAlias www.domain2.com
    ...
</VirtualHost>

2 Answers 2

1

CMIIW,

i think you must pass the Host header also

    proxy_set_header        Host            $host;

    proxy_set_header        X-Real-IP       $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
1
  • Accepting this answer because it was correct. After removing and creating a new wordpress it now works. Oct 22, 2010 at 7:51
1

Note that the HTTP Host header is not forwarded ...

nginx proxy_pass documentation

3
  • So my best option is having Apache listen to two different ports? Any downsides to that? Oct 21, 2010 at 19:39
  • That would be one way to do it. I don't see any immediate downsides which would not also apply to your present configuration (aside from opening up another port).
    – danlefree
    Oct 21, 2010 at 19:54
  • Turns out I really need that original IP passed for wordpress :/ Will keep looking. Oct 21, 2010 at 20:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .