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.

So, we're using Node.js to power CompassionPit.com, and it's all served up by nginx.

nginx is throwing a 504 Gateway Time-out

The interesting thing, however, is that if I navigate to http://compassionpit.com/index.html, then I can access the page (I believe the requested is routed through the Node app which is running on port 8000).

And http://compassionpit.com/blog/ is working.

But http://compassionpit.com/ is down. :(

Help?

root@li70-243:~# cat /etc/nginx/sites-enabled/blog
server {
    listen       80 default;                # your server's public IP address
    server_name  compassionpit.com;
    index        index.html;

    location /blog/wp-content/ {
        alias /opt/blog/wp-content/;
    }

    location /blog/ {
        root /opt/;

        include        fastcgi_params;
        fastcgi_pass   localhost:8080;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    }

    location / {
        alias /opt/chat/static/;

        if (-f $request_filename) {
            break;
        }
        if (!-f $request_filename) {
            proxy_pass  http://127.0.0.1:8000;
        }
    }

}

root@li70-243:~# cat /etc/nginx/nginx.conf 
user www-data;
worker_processes  1;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
    # multi_accept on;
}

http {
    include       /etc/nginx/mime.types;
    default_type application/octet-stream;

    access_log  /var/log/nginx/access.log;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    tcp_nodelay        on;

    gzip  on;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

root@li70-243:~# free
             total       used       free     shared    buffers     cached
Mem:        509868     394168     115700          0      43540     215296
-/+ buffers/cache:     135332     374536
Swap:       524284          0     524284
share|improve this question

migrated from stackoverflow.com Aug 22 '11 at 19:36

This question came from our site for professional and enthusiast programmers.

    
It's also possible that the Node app died...or is only partially working –  Zachary Burt Apr 28 '11 at 7:57

1 Answer 1

up vote 1 down vote accepted

Try this instead of your location / :

location / {
    alias /opt/chat/static/;
    try_files $uri @nodejs;
}

location @nodejs {
    proxy_pass  http://127.0.0.1:8000;
}

And always inspect error.log, it's your best friend.

share|improve this answer

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.