Could be a timing issue or some kind of (backend) control nginx is (yet) unaware of.
I wrote a small piece about this, which should make thing clearer but not solve it strait away:
=====================
The historical psychology of cgi and proxy(backend).
CGI: has never been (or designed as) a frontend, it always expects to talk to a downstream.
Proxied-backend: has always been a frontend, was never intended to be a backend, in most cases does not know what a frontend is.
Inherently this is where most proxy problems stem from, you have to talk to someone in a different language without knowing which language it speaks (protocol), different continent without knowing where (latency) and not knowing what to expect in return (does it understand me? / return code & error handling)
=====================
Your best bet is to enable debug mode to see which part of the process is 'waiting' for 'what'.
I wrote a small piece about this, which should make thing clearer but not solve it strait away:
=====================
The historical psychology of cgi and proxy(backend).
CGI: has never been (or designed as) a frontend, it always expects to talk to a downstream.
Proxied-backend: has always been a frontend, was never intended to be a backend, in most cases does not know what a frontend is.
Inherently this is where most proxy problems stem from, you have to talk to someone in a different language without knowing which language it speaks (protocol), different continent without knowing where (latency) and not knowing what to expect in return (does it understand me? / return code & error handling)
=====================
Your best bet is to enable debug mode to see which part of the process is 'waiting' for 'what'.