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 would like to serve multiple sites on one instance.

I install nginx, php-fpm, and a rails app. I use sites like this to guide me.

I configure php-fpm to listen to a local socket

listen = /var/run/php-fpm/php-fpm.sock

I configure ngnix with multiple hosts:

include /etc/nginx/conf.d/*.conf

I have several site php conf files like /etc/nginx/conf.d/site1.conf

server {
    listen 80; 
    server_name site1.com www.site1.com;

    root /var/www/site1;

    access_log /var/log/nginx/site1.com-access.log;
    error_log /var/log/nginx/site1.com-error.log;

    location / { 
        index index.html index.php;
    }   
    location ~ \.php$ {
        fastcgi_pass        unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index       index.php;
        include             fastcgi_params;
        fastcgi_param       PATH_INFO $fastcgi_script_name;
        fastcgi_param       SCRIPT_FILENAME $document_root/$fastcgi_script_name;
    }       
}

and rails site conf files like

upstream rails {
    server 127.0.0.1:3000;
}

server {
    listen 80;
    server_name site2.com www.site2.com;

    access_log /var/log/nginx/site2.com-access.log;
    error_log /var/log/nginx/site2.com-error.log;

    root /var/www/site2;

    location / {
        proxy_pass                       http://rails;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host            $host;
        proxy_set_header X-Url-Scheme    $scheme;
    }
}

I have a unicorn rails server running via rails s -p 3000

Yet, no sites come up for either site1.com or site2.com. I can get to the rails site at www.site2.com:3000

What is wrong? I've spent 2 days (nearly 30hr) trying many different blogs, SO / SF questions, etc. Please share your insight or answer.

edit 1: No log entries are created when I try to visit either site. It's like the requests never come in.

share|improve this question
    
I don't see any error messages or log entries. What errors did you receive and what was logged? –  Michael Hampton Sep 4 '12 at 5:37
    
@MichaelHampton the logs are empty for these requests. (there's only older stuff for upstream misconfigurations I had made before) –  New Alexandria Sep 4 '12 at 14:32
    
Because you didn't specify an error_log directive. –  quanta Sep 4 '12 at 15:42
    
@quanta i did, I just thought I"d simplify the code in my question. I've re-added it for 'certainty' –  New Alexandria Sep 4 '12 at 16:20
1  
Append debug to the end of error_log line, try again and post the logs here. –  quanta Sep 4 '12 at 16:24
show 1 more comment

1 Answer

up vote 0 down vote accepted

Always check your firewall / proxy / incoming ports.

Everything in the above config files works perfectly fine. The problem was that port 80 wasn't open to inbound traffic.

share|improve this answer
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.