You can use a any reverse proxy, such as HAProxy, Nginx, or any other solution to route
traffic in containerized, Kubernetes, or cloud environments with necessary timeout values. If the
timeout values are set less than the required values, it can result in unexpected behavior or
interruptions in your applications.
Procedure
- Access the reverse proxy host by logging in to the
server/VM/container/node where the reverse proxy is running. Ensure that you have
sufficient privileges to change the configurations.
Note: The following examples are demonstrated using HAProxy as the reverse proxy solution. However,
the configurations and steps provided are applicable to other reverse proxy providers as
well.
- Locate the configuration directory. The configuration files can be found in
/etc directory. Generally, configuration file for HAProxy can be found in
/etc/haproxy/haproxy.cfg
- Create a backup of the existing configuration. Back-up before changing the configuration
files of the proxy
server.
cp <config-file> <config-file>_$(date +%Y-%m-%d-%H-%M-%S)
for
example ,
cp haproxy.cfg haproxy.cfg_$(date +%Y-%m-%d-%H-%M-%S)
- Update the reverse proxy configuration for timeouts
Table 1. Timeout
Parameters
| Parameter |
Value |
Description |
| http-request |
120 s |
Maximum time to wait for a complete HTTP request from the client |
| queue |
1 m |
Maximum time a connection waits in the queue when all backend servers are saturated |
| connect |
120 s |
Maximum time to wait for a connection attempt to a backend server to succeed |
| client |
5 m |
Maximum inactivity time on the client side |
| server |
5 m |
Maximum inactivity time on the server side |
| http-keep-alive |
120 s |
Maximum time to wait for a new HTTP request on a keep-alive connection |
| check |
30 s |
Additional timeout for health checks |
Note: `s` represents seconds and `m` represents minutes.
- Example snippet for the configuration changes
defaults
mode http
log global
option httplog
option dontlognull
option http-server-close
option redispatch
retries 3
timeout http-request 120s
timeout queue 1m
timeout connect 120s
timeout client 5m
timeout server 5m
timeout http-keep-alive 120s
timeout check 30s
maxconn 3000
- Validate the configuration file and run the proxy’s built-in config. Fix the validation
errors before proceeding, if
any.
haproxy -c -f <config-file
for
example
haproxy -c -f /etc/haproxy/haproxy.cfg
- Restart the reverse
proxy
systemctl restart <proxy-service>
for
example
systemctl restart haproxy
- Verify proxy
functionality
systemctl status <proxy-service>
for
example
systemctl status haproxy