Loading...

No keep alive in Nginx

:heavy_exclamation_mark: This post is older than a year. Consider some information might not be accurate anymore. :heavy_exclamation_mark:

Providing a HTTP health check service with Nginx, is straightforward. If you do ensure that Nginx closes the HTTP connection instead keeping it alive. The basic option therefore is:

Syntax: keepalive_timeout timeout [header_timeout];
Default: keepalive_timeout 75s;
Context: http, server, location

The first parameter sets a timeout during which a keep-alive client connection will stay open on the server side. The zero value disables keep-alive client connections. The optional second parameter sets a value in the “Keep-Alive: timeout=time” response header field.

In order to disable keep-alive do keepalive_timeout 0;.

server {
    listen 445;
    location / {
        keepalive_timeout 0;
        root /usr/share/nginx/html;
    }
    access_log off;
}
Please remember the terms for blog comments.