标签:
安装haproxy
apt-get install haproxy
安装、配置rsyslog
apt-get install rsyslog
vi /etc/rsyslog.d/haproxy.conf
加入以下内容:
$ModLoad imudp
$UDPServerRun 514
local0.* /var/log/haproxy.log
保存, 重启rsyslogd.
1.方式一:
sudo cat /etc/haproxy/haproxy.cfg global log 127.0.0.1 local0 log 127.0.0.1 local1 notice chroot /var/lib/haproxy user haproxy group haproxy daemon maxconn 4096 defaults log global contimeout 5000 clitimeout 50000 srvtimeout 50000 maxconn 2000 retries 2 frontend test bind :8080 default_backend back_test frontend sshd bind :22 default_backend back_sshd ###################################################### backend back_httpd mode http option httpclose balance source #option httpchk HEAD /index.html HTTP/1.0 server www www.j(⊙o⊙)09.com:80 cookie www01 check fall 3 weight 1 server bbs bbs.j(⊙o⊙)09.com:80 cookie www02 check fall 3 weight 1 backend back_sshd mode tcp option tcpka balance roundrobin server vpn1 127.0.0.1:22 check server cs 172.31.21.143:22 check server sh 172.31.25.120:22 check backend back_test mode http stats enable stats refresh 300s stats uri /status stats realm Haproxy statistics stats auth admin:admin stats hide-version #####################################################
2.方式二:
ubuntu@ip:~$ cat /etc/haproxy/haproxy.cfg global log 127.0.0.1 local0 log 127.0.0.1 local1 notice chroot /var/lib/haproxy user haproxy group haproxy daemon maxconn 4096 defaults log global contimeout 5000 clitimeout 50000 srvtimeout 50000 maxconn 2000 retries 2 ################################################# listen default #web界面统计图 bind :80 mode http stats enable stats refresh 300s stats uri /status stats realm Haproxy statistics stats auth admin:admin #stats hide-version ##################################################### listen back_httpd :80 mode http option httpclose balance source #option httpchk HEAD /index.html HTTP/1.0 server www www.jk409.com:80 cookie www01 check fall 3 weight 1 server bbs bbs.jk409.com:80 cookie www02 check fall 3 weight 1 listen back_sshd :22012 mode tcp option tcpka balance roundrobin server vpn1 127.0.0.1:22 check server cs 172.1.1.13:22 check server sh 172.1.5.10:22 check #####################################################
标签:
原文地址:http://my.oschina.net/jk409/blog/423805