1. Installing Haproxy
Yum-y Install Haproxy
2. Configuration files
# this config needs haproxy-1.1. -or haproxy-1.2.1Global Log127.0.0.1local0 Log127.0.0.1local1 Notice #log loghost local0InfoMaxconn4096 chroot/usr/share/haproxy UID AboutGID Aboutdaemon #debug #quiet Defaults log global mode HTTP option Httplog Option Dontlognull Retries3Redispatch Maxconn -Contimeout theClitimeout50000Srvtimeout50000Listen Appli1-rewrite0.0.0.0:10001cookie ServerID rewrite balance roundrobin server app1_1192.168.34.23:8080Cookie App1inst1 Check Inter -Rise2Fall5Server App1_2192.168.34.32:8080Cookie App1inst2 Check Inter -Rise2Fall5Server App1_3192.168.34.27:8080Cookie App1inst3 Check Inter -Rise2Fall5Server App1_4192.168.34.42:8080Cookie App1inst4 Check Inter -Rise2Fall5Listen Appli2-insert0.0.0.0:10002option Httpchk Balance Roundrobin cookie ServerID Insert indirect nocache server Inst1 192.168.114.56: theCookie Server01 Check Inter -Fall3Server Inst2192.168.114.56:BayiCookie Server02 Check Inter -Fall3Capture Cookie Vgnvisitor= Len +Option Httpclose # Disable Keep-Alive Rspidel^set-cookie:\ ip= # DoNot let this cookie tell our internal IP address Listen Appli3-relais0.0.0.0:10003Dispatch192.168.135.17: theListen Appli4-backup0.0.0.0:10004option Httpchk/index.html option persist balance Roundrobin server Inst1192.168.114.56: theCheck Inter -Fall3Server Inst2192.168.114.56:BayiCheck Inter -Fall3Backup Listen SSL-relay0.0.0.0:8443option SSL-hello-chk Balance Source server Inst1192.168.110.56:443Check Inter -Fall3Server Inst2192.168.110.57:443Check Inter -Fall3Server Back1192.168.120.58:443Backup Listen appli5-backup0.0.0.0:10005option Httpchk*Balance Roundrobin cookie ServerID Insert Indirect nocache server Inst1192.168.114.56: theCookie Server01 Check Inter -Fall3Server Inst2192.168.114.56:BayiCookie Server02 Check Inter -Fall3Server Inst3192.168.114.57: theBackup Check Inter -Fall3capture Cookie Aspsession Len +Srvtimeout20000Option Httpclose # Disable Keep-Alive Option Checkcache # block ResponseifSet-cookie &cacheable Rspidel^set-cookie:\ ip= # DoNot let this cookie tell our internal IP address Errorloc502http//192.168.114.58/error502.htmlErrorFile503/etc/haproxy/errors/503. http
Haproxy One of the notes: Haproxy Basic Installation configuration (reverse proxy, like Nginx, can proxy TCP connections, not just HTTP) (note iptables and selinux issues)