- Install Haproxy
Centos/rhel 5, bit:
# RPM-UVH http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
Centos/rhel 5, bit:
# RPM-UVH http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
Centos/rhel 6, bit:
# RPM-UVH http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
Centos/rhel 6, bit:
# RPM-UVH http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Yum-y Install Haproxy
- Configure Haproxy
Vi/etc/haproxy/haproxy.cfg
Global Log127.0.0.1local0 Log127.0.0.1local1 Debug Maxconn45000# Total Max Connections. Daemon Nbproc1# Number of processing cores. Defaults log global mode HTTP option httplog option Dontlognull Retries3option Redispatch maxconn20000Timeout Server86400000Timeout Connect86400000Timeout Client86400000Timeout Queue 1000s # [HTTP Site configuration]listen http_web192.168.10.10: themode http Balance roundrobin # Load balancing algorithm option HTTPCHK option forwardfor Server Server1192.168.10.100: theWeight1Maxconn +Check server Server2192.168.10.101: theWeight1Maxconn +check# [HTTPS Site configuration]listen https_web192.168.10.10:443mode TCP balance source# Load balancing algorithm Reqadd X-forwarded-proto:\ http Server Server1192.168.10.100:443Weight1Maxconn +Check server Server2192.168.10.101:443Weight1Maxconn +Check # [change HAProxy Stats url]listen Stats192.168.10.10:1936mode HTTP log global balance Roundrobin maxconnTenclitimeout 100s srvtimeout 100s contimeout 100s Timeout queue 100s Stats Enable stats Hide-version Stats refresh 30s stats show-node Stats Realm haproxy\ Statistics stats auth admin:password stats URI/ha-stats or stats URI/stats
haproxy.cfg CodeOpen firewall 1936 Port
- Restart related services
Service Iptables Restart
Service Haproxy Restart
Chkconfig Haproxy on
- Backstage View site:
Http://192.168.10.10:1936/ha-stats or Http://192.168.10.10:1936/stats
- Reference Links:
http://tecadmin.net/install-and-configure-haproxy-on-centos/
How to Intall and configure Haproxy on Centos