Networking
HAProxy tutorial
HAProxy je nejrozšířenější open-source load balancer.
Instalace
sudo apt install haproxy
sudo systemctl enable --now haproxy
Konfigurace
global
maxconn 50000
defaults
mode http
timeout connect 5s
timeout client 30s
timeout server 30s
frontend web
bind *:80
bind *:443 ssl crt /etc/ssl/site.pem
redirect scheme https if !{ ssl_fc }
default_backend servers
backend servers
balance roundrobin
option httpchk GET /health
server web1 10.0.1.1:3000 check
server web2 10.0.1.2:3000 check
server web3 10.0.1.3:3000 check backup
Stats
listen stats
bind *:8404
stats enable
stats uri /stats
- ACL routing — URL, headers, cookies
- Rate limiting — stick tables
- Connection draining — graceful shutdown
- SSL termination
HAProxy = spolehlivost
Battle-tested load balancer pro produkci.