参考
https://www.cnblogs.com/nihaorz/p/10783249.html
config
globallog 127.0.0.1 local0log 127.0.0.1 local1 noticemaxconn 4096#chroot /usr/share/haproxy#user haproxy#group haproxydaemondefaults log global mode http option httplog option dontlognull retries 3 option redispatch timeout connect 5000 timeout client 50000 timeout server 50000# 统计页面配置listen admin_stats bind 0.0.0.0:50000 # 监听IP和端口,为了安全可以设置本机的局域网IP及端口; mode http option httplog # 采用http日志格式 stats refresh 30s # 统计页面自动刷新时间 stats uri /haproxy?stats # 状态管理页面,通过/haproxy?stats来访问 stats realm Haproxy Manager # 统计页面密码框上提示文本 stats auth admin:psadmin # 统计页面用户名和密码设置 #stats hide-version # 隐藏统计页面上HAProxy的版本信息 #errorfile 403 /usr/local/haproxy/examples/errorfiles/ #设置haproxy 错误页面frontend fe_k8s_6444 bind *:6444 mode tcp timeout client 1h log global option tcplog default_backend be_k8s_6443 acl is_websocket hdr(Upgrade) -i WebSocket acl is_websocket hdr_beg(Host) -i wsbackend be_k8s_6443 mode tcp timeout queue 1h timeout server 1h timeout connect 1h log global balance roundrobin server rancher01 192.168.75.161:6443 server rancher02 192.168.75.162:6443 server rancher03 192.168.75.163:6443
运行
docker run -d -p 8080 -p 30001 --name haproxy -v /root/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro haproxy:1.9.11