Deploy haproxy in centOS
Down load haproxy from http://haproxy.1wt.eu/
We could use wget http://haproxy.1wt.eu/download/1.4/src/haproxy-1.4.20.tar.gz
Extract the package.
tar -xzvf haproxy-1.4.20.tar.gz
We could use wget http://haproxy.1wt.eu/download/1.4/src/haproxy-1.4.20.tar.gz
Extract the package.
tar -xzvf haproxy-1.4.20.tar.gz
compile and install.
cd haproxy-1.4.20.tar.gz
make TARGET=linux26 PREFIX=/home/khisserver/haproxy install
Copy the haproxy to /usr/sbin/haproxy
cp /home/khisserver/haproxy/sbin/haproxy /usr/bin/haproxy
Add config file.
wget http://layer1.rack911.com/haproxy/haproxy-standard.cfg -O /etc/haproxy.cfg
wget http://layer1.rack911.com/haproxy/haproxy.init -O /etc/init.d/haproxy
chmod +x /etc/init.d/haproxy
wget http://layer1.rack911.com/haproxy/haproxy.init -O /etc/init.d/haproxy
chmod +x /etc/init.d/haproxy
Update the haproxy.cfg to the following contents.
globalmaxconn 4096 # Total Max Connections. This is dependent on ulimitdaemonnbproc 1 # Number of processing cores. Dual Dual-core Opteron is 4 cores for example.defaultsmode httpclitimeout 60000srvtimeout 30000contimeout 4000option httpclose # Disable Keepalivelisten admin_statsbind 0.0.0.0:1080mode httpstats uri /admin?statslisten http_proxy 150.245.172.34:8081 #This should be your current ip addressbalance roundrobin # Load Balancing algorithmoption httpchkoption forwardfor # This sets X-Forwarded-For## Define your servers to balanceserver server1 150.245.167.59:8080 weight 1 maxconn 512 check#server server2 150.245.172.60:8080 weight 1 maxconn 512 check
Start haproxy :
service haproxy start
[root@null-000c29b19d60 Desktop]# service haproxy start
Starting HAproxy: [ OK ]
You have new mail in /var/spool/mail/root
Starting HAproxy: [ OK ]
You have new mail in /var/spool/mail/root
Open browser:
http://150.245.172.34:8081/ It will redired to 150.245.167.59:8080
Open managerment web site: