Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a server with one IP address and multiple domains. I want NGINX to run on port 80 and redirect all domains to Apache (port 8000), except one domain which I want it to redirect to gunicorn instance i'm running.

I tried the following, but ALL sites redirect to apache's Test Page(!):

Nginx:

# gunicorn site:
server {
    server_name gunicorn.domain;
    location / {
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_redirect off;
      proxy_pass http://127.0.0.1:9006;
}
}
# apache sites:
server {
    server_name apache.domain;
    location / {
      proxy_pass http://127.0.0.1:8000;
      proxy_set_header Host $http_host;
    }
}
server {
    server_name apache.domain2;
    location / {
      proxy_pass http://127.0.0.1:8000;
      proxy_set_header Host $http_host;
    }
}

Apache has different VirtualHost directives for the domains i'm redirecting. However, all I get is Apache's test page, even when accessing gunicorn.domain.

share|improve this question
    
Can't see anything wrong about your config. But usually for debugging its really helpful to have separate access logs for each vhost. That way you can be really sure which of your vhosts has handled the request. –  mauro.stettler Feb 17 '13 at 8:06
    
Btw. I just realized you don't seem to have a listen directive for your servers. Maybe the reason why your vhosts aren't used is because you didn't specify on which port they should listen. wiki.nginx.org/HttpCoreModule#listen –  mauro.stettler Feb 17 '13 at 8:16
    
The listen directive did not really help.. I noticed that when I remove all the apache sites from the configuration the gunicorn site works. It seems like the server directives do no handle the hostname correctly. –  Joel Feb 17 '13 at 9:03
    
Tru adding access logs for each vhost. Then you can see more details about the request that arrived at the nginx and which vhost has handled it. –  mauro.stettler Feb 17 '13 at 9:17
    
The first listed apache vhost handles all requests (regardless of the real host name) –  Joel Feb 17 '13 at 9:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.