Skip to content
gohacks.dev
DevOps

HAProxy Config Generator

Generate an HAProxy configuration for HTTP load balancing with TLS termination, an HTTPS redirect, HTTP health checks, sticky sessions and a stats page.

Free · No sign-up · Your inputs stay in your browser

Input

Generate an HAProxy load balancer config

Output

/etc/haproxy/haproxy.cfg

1,176 characters

HAProxy reads the certificate and key from one PEM file: cat fullchain.pem privkey.pem > the .pem named here. A server is taken out after three failed checks two seconds apart and returned after two good ones. Check with haproxy -c -f /etc/haproxy/haproxy.cfg before reloading.

Runs in this browser. Nothing you paste is sent to a server.

Choosing the algorithm

roundrobin sends requests in turn and suits short, uniform requests; leastconn sends each to the server with the fewest open connections and suits uneven or long requests such as uploads and websockets; source hashes the client IP for crude stickiness. The HAProxy documentation lists the rest.

Health checks

With check inter 2s fall 3 rise 2, a server is removed after three failed checks and returned after two good ones. The check should hit an endpoint that tests what the app needs (database, cache) without being expensive, and return 200 only when the instance can serve traffic.

Share

Frequently asked questions

How do I give HAProxy a certificate?
Concatenate the full chain and the private key into one PEM file and point bind ... ssl crt at it, or at a directory of such files for several domains.
How do I reload HAProxy without dropping connections?
Check the file with haproxy -c -f /etc/haproxy/haproxy.cfg, then systemctl reload haproxy. The new process takes over the sockets while the old one finishes its connections.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools