Proxy module buffering and timeouts

Maxim Dounin mdounin at mdounin.ru
Fri Sep 4 13:58:06 UTC 2015


Hello!

On Fri, Sep 04, 2015 at 08:42:54AM -0400, donatasm wrote:

[...]

> but also i sometimes randomly get partially cut responses:
> 
> curl -i http://localhost:7070/demo
> 
> HTTP/1.1 200 OK
> Server: nginx/1.9.4
> Date: Fri, 04 Sep 2015 12:24:35 GMT
> Content-Type: text/plain
> Content-Length: 27
> Connection: keep-alive
> 
> curl: (18) transfer closed with 27 bytes remaining to read
> 
> How this can be fixed?

By fixing your backend to return a full response or not return it 
at all.

> Since proxy buffering is on, i expect nginx always
> return either  502 error page on upstream timeout or a response from an
> upstream.

No, this is wrong expectation.  Buffering means that nginx will 
avoid doing an extra work for partially filled body buffers, and 
it will be allowed to buffer parts of a response in the filter 
chain.  No attempt will be made to obtain a full response and 
check it's length (and such a behaviour is not at all possible if 
the response is big enough).  As long as a response header is 
received from an upstream server, it will be passed to the client, 
and then nginx will start proxying the response body.  An error 
can be returned only if the header was not yet passed to the 
client.

-- 
Maxim Dounin
http://nginx.org/



More information about the nginx mailing list