502 Bad Gateway error for my server running Node JS on nginx proxy
I am getting 502 bad gateway error: when I check the nginx error log, I find this:
2017/05/06 02:36:04 [error] 48176 # 0: * 135 connect () failed (111: connection refused) while connecting to upstream, client: 10.163.XX.X, server: abc-def - ghi, request: "GET / favicon.ico HTTP / 1.1", upstream: " https://127.0.0.1:5300/favicon.ico ", host: "hostnname", referrer: "hostname-1
I've searched internet enough but couldn't find anything. It's worth noting here that this intermittent error only arrives on a specific page.
Could this be a code issue? or nginx setup problem> Can anyone help me here.
Some of my nginx conf:
upstream node_api_server {
server localhost:5300 fail_timeout=0;
}
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_read_timeout 5m;
proxy_connect_timeout 5m;
proxy_pass_header Set-Cookie;
proxy_pass https://node_api_server;
proxy_redirect off;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
break;
}
+3
source to share
3 answers