How to disable the keepalive timeout for nginx?
To disable the keepalive timeout for Nginx, you need to follow these steps:
- Open the Nginx configuration file, which is typically located at /etc/nginx/nginx.conf or /etc/nginx/conf.d/default.conf. You can use any text editor to open it.
- Locate the HTTP block in the configuration file, which is typically found in the form of http { … }.
- Add the following command in the HTTP block to set the keepalive timeout to 0 seconds:
keepalive_timeout 0;
- Save and close the configuration file.
- Reload the Nginx configuration. You can use the following command to reload the configuration file:
sudo systemctl reload nginx
Currently, Nginx’s keepalive timeout has been set to 0 seconds, which means the connection will close immediately.