Skip to content

maxuru ~ % cat haproxy/timeouts-and-limits

Set HAProxy timeouts and connection limits

Severity: lowApplies to: HAProxy 2.xApplies to: HAProxy 3.x
The fix/etc/haproxy/haproxy.cfg
defaults
timeout http-request 10s
timeout connect 5s
timeout client 30s
timeout server 30s
timeout http-keep-alive 10s
timeout queue 30s
global
maxconn 20000

Because it is availability, not compromise. Nothing here stops an intrusion or protects data — a proxy that falls over under a slowloris attack is an outage, and outages are recoverable in a way that a breach is not. It sits at the bottom of the checklist for that reason, and the pages above it are worth doing first.

That said, it is genuinely cheap, and the one timeout that matters most is frequently missing.

timeout http-request limits how long a client may take to send its complete request headers. It is the direct answer to slowloris-style attacks: opening many connections and dribbling headers a byte at a time, holding a slot open on the proxy indefinitely.

It is distinct from timeout client, which governs inactivity on an established connection and is usually set generously to accommodate slow uploads and long polls. A generous timeout client with no timeout http-request leaves the header-reading phase effectively unbounded.

Ten seconds is ample for a real client, which sends its headers in one burst.

Timeout Bounds
connect Waiting for a backend server to accept the TCP connection
client Client-side inactivity once the connection is established
server Waiting for the backend to respond
http-keep-alive Idle time between requests on a kept-alive connection
queue How long a request waits for a free server slot before failing

Omitting timeout client or timeout server in defaults produces a warning at startup, because a connection with no timeout on either side can be held until the process restarts.

maxconn caps concurrent connections process-wide. Left unset it takes a value derived from the file descriptor limit, which means your capacity ceiling is whatever ulimit -n happened to be — a number nobody chose.

Set it explicitly, below what the host can actually sustain in memory. HAProxy queues beyond the limit rather than crashing, which is the behaviour you want: predictable refusal instead of the machine going down. Per-backend maxconn on server lines is separate and protects the backend from being overwhelmed while HAProxy absorbs the queue.

backend app
server app1 10.0.1.10:8080 check maxconn 200