I´m having same issue with a backend with nodejs. My configuration is pretty similar and have also tested changing connection type with no luck (missing requests on my backend and a timeout of 60 seconds until the request is resent).
<snip>
upstream node_app {
server localhost:3000 fail_timeout=5s;
keepalive 1;
}
</snip>
<snip>
location /api {
proxy_http_version 1.1;
proxy_set_header Connection "keep-alive";
proxy_pass http://node_app;
proxy_set_header X-Real-IP $remote_addr;
}
</snip>
On the log I´m getting the following error:
2014/01/30 10:32:32 [error] 6760#3604: *1 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET /api/xxxxx HTTP/1.1", upstream: "http://[::1]:3000/api/xxxxx", host: "localhost"
I have been monitoring the ports open with netstat -n and the port 3000, nginx is apparently using a closed socket (port) to send the second request (that is lost and after a minute is re-sent on a new socket/port)
I attach the debug log of two requests
<snip>
upstream node_app {
server localhost:3000 fail_timeout=5s;
keepalive 1;
}
</snip>
<snip>
location /api {
proxy_http_version 1.1;
proxy_set_header Connection "keep-alive";
proxy_pass http://node_app;
proxy_set_header X-Real-IP $remote_addr;
}
</snip>
On the log I´m getting the following error:
2014/01/30 10:32:32 [error] 6760#3604: *1 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET /api/xxxxx HTTP/1.1", upstream: "http://[::1]:3000/api/xxxxx", host: "localhost"
I have been monitoring the ports open with netstat -n and the port 3000, nginx is apparently using a closed socket (port) to send the second request (that is lost and after a minute is re-sent on a new socket/port)
I attach the debug log of two requests