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

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  
Update the haproxy.cfg to the following contents.
global
     maxconn     4096 # Total Max Connections. This is dependent on ulimit
     daemon
     nbproc      1 # Number of processing cores. Dual Dual-core Opteron is 4 cores for example.
defaults
     mode         http
     clitimeout  60000
     srvtimeout  30000
     contimeout  4000
     option      httpclose # Disable Keepalive
listen admin_stats
     bind 0.0.0.0:1080
     mode         http
     stats uri /admin?stats
listen     http_proxy 150.245.172.34:8081 #This should be your current ip address
     balance     roundrobin # Load Balancing algorithm
     option httpchk
     option forwardfor # This sets X-Forwarded-For
     ## Define your servers to balance
     server 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
Open browser:
     http://150.245.172.34:8081/  It will redired to  150.245.167.59:8080 
     
     Open managerment web site:
     

posted on 2012-04-10 10:01  Paul_  阅读(155)  评论(0编辑  收藏  举报

导航