Install HAProxy on AlmaLinux 9
Step 1 – Install
dnf install -y haproxy
systemctl enable --now haproxy
Step 2 – Basic /etc/haproxy/haproxy.cfg
global
log /dev/log local0
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
user haproxy
group haproxy
daemon
defaults
log global
mode http
option httplog
timeout connect 5s
timeout client 50s
timeout server 50s
frontend http-in
bind *:80
default_backend webservers
backend webservers
balance roundrobin
option httpchk GET /health
server web1 192.168.1.10:80 check
server web2 192.168.1.11:80 check
server web3 192.168.1.12:80 check
listen stats
bind *:8404
stats enable
stats uri /
stats refresh 10s
stats auth admin:haproxypass
Step 3 – Validate and reload
haproxy -c -f /etc/haproxy/haproxy.cfg
systemctl reload haproxy 2>/dev/null || rcctl reload haproxy 2>/dev/null || rc-service haproxy reload