yum install haproxy |
setsebool -P haproxy_connect_any=1 |
global log /dev/log local0 log /dev/log local1 notice maxconn 1024 user haproxy group haproxy daemon nbproc 1 pidfile /var/run/haproxy.pid tune.ssl.default-dh-param 1024 defaults log global mode http option httplog option dontlognull timeout server 30s timeout connect 30s timeout client 30s retries 2 # Web 服務入口 frontend switch bind *:80 mode http option httpclose option forwardfor reqadd X-Forwarded-Proto:\ https default_backend web_server_cluster # HAProxy 監控儀表板 listen stats :8080 mode http stats enable stats hide-version stats realm Haproxy\ Statistics stats uri / # 帳號密碼 stats auth your_username:your_password stats refresh 10s # 設定 Web Cluster backend web_server_cluster mode http balance roundrobin cookie SERVERID insert indirect nocache # Web Server Cluster server web1 192.168.1.10:80 check cookie s1 server web2 192.168.1.11:80 check cookie s2 |