I. Introduction to the Environment
1.centos6
2. haproxy-1.4.25.tar.gz
Two. Installation
$ Curl-o http://haproxy.1wt.eu/download/1.4/src/haproxy-1.4.25.tar.gz$ tar zxvf haproxy-1.4. -. tar.gz$ CD Haproxy-1.4. -$ make TARGET=linux26 prefix=/usr/local/haproxy$ make install PREFIX=/usr/local/haproxy$ CP Examples/haproxy.cfg/usr/local/haproxy/$ CP Examples/haproxy.init/etc/init.d/haproxy$ chmod755/etc/init.d/haproxy$ Ln-s/usr/local/haproxy/etc/$ ln-s/usr/local/haproxy/sbin/haproxy/usr/sbin/$ groupadd haproxy$ useradd-G Haproxy haproxy-s/sbin/nologin-m$ grep haproxy/etc/passwdhaproxy:x:507:507::/home/haproxy:/sbin/nologin
Three. Configuration
$ vi/etc/haproxy/haproxy.cfgGlobalLog127.0.0.1local0 Log127.0.0.1local1 Notice #log loghost local0 info maxconn40960chroot/usr/local/haproxy UID803GID803Daemon Nbproc1#debug #quietdefaults LogGlobalmode HTTP option httplog option dontlognull option forwardfor option Httpclose retries 3option Redispatch maxconn -Timeout Connect500000Timeout Client5000000Timeout Server50000000frontend http-inchBind192.168.233.2: themode HTTP option httplog logGlobalACL is_a Hdr_beg (host)-i www.test.com ACL is_a Hdr_beg (host)-i test.com use_backend a_serverifis_a stats Enable stats hide-version stats URI/admin-Status Stats auth admin:admin123 stats adminifTRUE backend a_server balance Roundrobin cookie Session_cookie insert indirect nocache option HTTP CHK HEAD/default.aspx http/1.0Fullconn10000Server web58192.168.233.158: theMinconn -Maxconn +Cookie Web1 Weight6Check Inter -Rise2Fall4Server web85192.168.233.185: theMinconn -Maxconn +Cookie WEB2 Weight6Check Inter -Rise2Fall4
Four Start
/etc/init.d/haproxy start
Centos Compiler Installation Haproxy