I've played with proxy timeout settings, no luck. And nothing was logged on the backend-server.
Finally I've found something in the firewall log:
May 27 10:25:06 APZRP01 kernel: DROP: IN=APZRP01 OUT= MAC=c4:34:6b:af:19:64:e8:65:49:28:08:77:08:00 SRC=10.59.55.245 DST=192.168.57.14 LEN=40 TOS=0x00 PREC=0x00 TTL=128 ID=24114 DF PROTO=TCP SPT=39134 DPT=80 WINDOW=0 RES=0x00 ACK RST URGP=0
disabling iptables and changing to firewalld on centos - nothing changed. Searching on google for this problem brings up some reports for this behaviour, but not a solution. The problem is easy to reproduce, start nginx proxy, access the upstream - no problem. wait an hour,...
2016/05/26 23:35:32 [error] 4908#5116: *27528 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 reading response header from upstream,...
after a few seconds the backend responds again perfectly for hours, but after a time of no traffic the problem occurs again, with 10 and 60 seconds on the proxy_timeout