Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Nginx Service Optimization (5) setting connection timeout

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

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]#

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report