keepalive and 5xx

Frank Liu gfrankliu at gmail.com
Tue Jul 10 23:59:43 UTC 2018


Hi Maxim,

When you say "Keepalive is automatically switched off...", do you mean
nginx will send "Connection: close" as part of the response? What happens
if client doesn't honor that, and keeps sending another request to the
existing connection?

You also mentioned "error codes is generated by nginx itself", so what
happens if nginx is used as reverse proxy, and the error code is coming
from upstream? Will nginx switch off keepalive with client too?

Thanks!
Frank


On Tue, Jul 10, 2018 at 10:04 AM, Maxim Dounin <mdounin at mdounin.ru> wrote:

> 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/
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20180710/f00453c0/attachment.html>


More information about the nginx mailing list