proxy module handling early responses

Maxim Dounin mdounin at mdounin.ru
Mon Jul 13 15:47:25 UTC 2020


Hello!

On Fri, Jul 10, 2020 at 09:40:52AM -0700, Frank Liu wrote:

> If you read the same RFC, section 6.5, right before the section you
> mentioned, you can see:
> 
>    A client sending a message body SHOULD monitor the network connection
>    for an error response while it is transmitting the request.  If the
>    client sees a response that indicates the server does not wish to
>    receive the message body and is closing the connection, the client
>    SHOULD immediately cease transmitting the body and close its side of
>    the connection.
> 
> In this case, server sent HTTP/413 (along with Connection: close) to
> indicate it did not wish to receive the message body. Does nginx
> immediately cease transmitting the body and close its side of the
> connection?

It does.  But "immediately" from nginx point of view can easily 
mean "way too late" from TCP stack point of view, resulting in 
nginx not being able to get the response at all.

To re-iterate: if the upstream server fails to do connection 
teardown properly, the only option is to fix the upstream server.  
This is not something which can be solved on nginx side.

Everthing which can be done on nginx side is believed to be 
already implemented, including sending to the client partially 
obtained responses with all the bytes nginx was able to read from 
the socket (if nginx was able to read at least the response 
headers).

-- 
Maxim Dounin
http://mdounin.ru/


More information about the nginx mailing list