nginx leads to 504 error, but my app is still running
13,411
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.
Related videos on Youtube
Author by
Zack Burt
Software engineer. Coauthor of Software Engineer's Guide to Freelance Consulting
Updated on September 18, 2022Comments
-
Zack Burt over 1 year
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
-
Admin about 13 yearsIt's also possible that the Node app died...or is only partially working
-