Get the App
SLTechnology News&Howtos  ›  Servers  › 

Nginx Service Optimization (5) setting connection timeout

Shulou Source: shulou.com Published: 2022-06-02 13:20:21 12月06日 Update

Configure Nginx to implement connection timeout

In the enterprise website, in order to avoid the same customer occupying the connection for a long time and causing resource waste, you can set the corresponding connection timeout parameter to control the connection access time.

1. Check connection parameters with "curl -I" command [root@localhost nginx]# curl -I 192.168.52.131HTTP/1.1 200 OKServer: nginx/1.1.1Date: Wed, 13 Nov 2019 11:06:54 GMTContent-Type: text/htmlContent-Length: 637Last-Modified: Wed, 13 Nov 2019 08:09:06 GMTConnection: keep-alive //No timeout ETag: "5dcbba22-27d"Accept-Ranges: bytes2. Modify nginx config file [root@localhost nginx]# vim conf/nginx.conf keepalive_timeout 65 180; //Connection keepalive timeout, 65 is server timeout, 180 is client timeout, in seconds client_header_timeout 80; //timeout waiting for client to send request header client_body_timeout 80; //Request body read timeout [root@localhost nginx]# service nginx restart //Restart the service [root@localhost nginx]# 3. Use the "curl -I" command again to check the connection parameters [root@localhost nginx]# curl -I 192.168.52.131HTTP/1.1 200 OKServer: nginx/1.1.1Date: Wed, 13 Nov 2019 11:08:28 GMTContent-Type: text/htmlContent-Length: 637Last-Modified: Wed, 13 Nov 2019 08:09:06 GMTConnection: keep-aliveKeep-Alive: timeout=180 //timeout ETag: "5dcbba22-27d"Accept-Ranges: bytes[root@localhost nginx]#

Tags: Time parameters customer service command client configuration enterprise enterprise website again unit header file website resource configurable long-term control Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft MySQL Shulou Technology Xiaomi macOS