keepalive and 5xx

Maxim Dounin mdounin at mdounin.ru
Tue Jul 10 17:04:41 UTC 2018


Hello!

On Mon, Jul 09, 2018 at 05:16:36PM -0700, Frank Liu wrote:

> Does nginx automatically disconnect keepalive connection if 5xx response
> code is generated?

Not really.  Keepalive is automatically switched off when a 
response with one of the following error codes is generated by 
nginx itself:

- 400 Bad Request
- 413 Request Entity Too Large
- 414 Request URI Too Large
- 500 Internal Server Error
- 501 Not Implemented

This is because such errors indicate that we might not be able 
to maintain protocol state properly, and hence we need to close 
the connection.

Details can be found in the ngx_http_special_response_handler() 
function, see here:

http://hg.nginx.org/nginx/file/tip/src/http/ngx_http_special_response.c#l428

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


More information about the nginx mailing list