ITeye博客

haproxy 实现代理

i-david · 2012-09-25 18:04 · 运维系统 · 开源软件 · Markdown

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

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。