源碼安裝
make TARGET=linux2628 PREFIX=/usr/local/haproxy
make install PREFIX=/usr/local/haproxy
全局配置
global
log 127.0.0.1 local3 info ## 設定日志
chroot /usr/local/haproxy ## 設定根目錄
user haproxy ## 使用者
group haproxy
daemon ## 守護程序啟動
maxconn 4000 # 最大連接配接數
預設配置
defaults
log global
mode http
timeout connect 5000
timeout client 50000
timeout server 50000
監聽端口
listen stats
bind *:80
mode http
stats uri /
stats hide-version
stats admin if TRUE
## 資料庫代理TCP
listen mysql_lb
bind *:3307
mode tcp
server mariadb1 127.0.0.1:3306 weight 1 check inter 2000 rise 2 fall 3
server mariadb2 10.0.2.85:3306 weight 1 check inter 2000 rise 2 fall 3
## SSH代理 TCP
listen ssh1
bind *:222
mode tcp
server mariadb1 10.0.2.85:22 weight