haproxy 实现代理

1,安装haproxy
mkdir -p /data/softwares/ 
cd /data/softwates/ 
wget http://haproxy.1wt.eu/download/1.4/src/haproxy-1.4.20.tar.gz 
tar xzvf haproxy-1.4.20.tar.gz -C /usr/local/ 
cd /usr/local/ 
mv haproxy-1.4.20 haproxy 
cd haproxy 
make TARGET=linux26
make install 

mkdir /etc/haproxy 
cp /usr/local/haproxy/examples/haproxy.cfg /etc/haproxy/
vi /etc/haproxy/haproxy.cfg 
echo '' > /etc/haproxy/haproxy.cfg



2,简单配置
global 
    log 127.0.0.1 local0 
    log 127.0.0.1 local1 notice 
    maxconn 4096 
    chroot /usr/share/haproxy 
    uid 99 
    gid 99 
    daemon 
    #debug 
    #quiet 
 
defaults 
    log global 
    mode http 
    option httplog 
    option dontlognull 
    retries 3 
    option redispatch 
    maxconn 2000 
    contimeout 5000 
    clitimeout 50000 
    srvtimeout 50000 
 
listen test-webservers 0.0.0.0:80 
    stats uri /check-status 
    stats realm Haproxy\ statistics 
    stats auth haproxy:haproxy 
    option httpchk * 
    balance roundrobin 
    cookie SERVERID insert indirect nocache 
    server inst1 192.168.1.54:80 cookie server01 check inter 2000 fall 3 
    capture cookie ASPSESSION len 32 
    srvtimeout 20000



3,运行
haproxy -f haproxy.cfg

你可能感兴趣的:(linux,nagios)