HAProxy Cheat Sheet
Configuration syntax for HAProxy frontends, backends, load-balancing algorithms, and health checks in high-availability setups.
2 PagesAdvancedFeb 10, 2026
Frontend & Backend
Route HTTP traffic to a pool of backend servers.
haproxy
frontend http_front bind *:80 default_backend http_backbackend http_back balance roundrobin option httpchk GET /healthz server web1 10.0.0.1:3000 check server web2 10.0.0.2:3000 check server web3 10.0.0.3:3000 check backup
SSL Termination
Terminate TLS at HAProxy and forward plaintext to backends.
haproxy
frontend https_front bind *:443 ssl crt /etc/haproxy/certs/example.pem mode http redirect scheme https code 301 if !{ ssl_fc } default_backend http_backfrontend http_redirect bind *:80 redirect scheme https code 301
Load-Balancing Algorithms
Common 'balance' directive values.
- roundrobin- Cycles requests evenly across servers; default and simplest choice
- leastconn- Sends new requests to the server with fewest active connections; good for long-lived connections
- source- Hashes client IP so the same client consistently hits the same server (sticky by IP)
- uri- Hashes the request URI, useful for cache-friendly routing
- static-rr- Round robin with weights fixed at start (no dynamic reweighing)
- first- Sends to the first server with available capacity, keeping others idle until needed
Stats Page & ACLs
Expose the built-in dashboard and route by path.
haproxy
listen stats bind *:8404 stats enable stats uri /stats stats refresh 10sfrontend http_front bind *:80 acl is_api path_beg /api use_backend api_back if is_api default_backend web_back
Pro Tip
Use 'option httpchk' with a dedicated lightweight health endpoint rather than checking '/', so backend health reflects application readiness, not just whether the web server process is alive.
Was this cheat sheet helpful?
Explore Topics
#HAProxy#HAProxyCheatSheet#DevOps#Advanced#FrontendBackend#SSLTermination#LoadBalancingAlgorithms#StatsPageACLs#Algorithms#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech
Professional Web Designing Services
- Responsive Websites
- E-commerce Solutions
- SEO Friendly Design
- Fast & Secure
- Support & Maintenance