# HAProxy configuration showing load balancing TCP
global
log 192.168.50.2:514 local0 info
chroot /var/lib/haproxy
user haproxy
group haproxy
defaults
log global
mode tcp
balance leastconn
option tcplog
timeout connect 5s
timeout client 5m
timeout server 5m
frontend fe_mysql
bind *:3306
default_backend be_mysql
backend be_mysql
stick-table type ip size 1m expire 1h
stick match src
stick store-request src
log-tag mysql
server db1 192.168.50.10:3306 check slowstart 60s weight 1
server db2 192.168.50.11:3306 check slowstart 60s weight 3
server db3 192.168.50.12:3306 check slowstart 60s backup
server db4 192.168.50.13:3306 check slowstart 60s backup
listen stats
bind :9999 ssl crt /etc/ssl/certs/mycert.pem
stats enable
stats uri /report
stats refresh 30s
http-request deny unless { src 192.168.50.0/24 }