Wednesday, August 11, 2010

HAproxy - LoadBalancer - balancing 3 squid's

Trying to loadbalance requests across 3 squid-cache proxys, very nice, i'm enjoiyng HAproxy a lot, great software.

Here it goes:

Client request <-----> HAproxy <---> squid1 \ 
                               <---> squid2  -- web
                               <---> squid3 /


Config file: haproxy.cfg

global
        log 127.0.0.1   local0
        log 127.0.0.1   local1 notice
        #log loghost    local0 info
        maxconn 4096
        #nbproc 2
        #chroot /usr/share/haproxy
        user haproxy
        group haproxy
        daemon
        #debug
        #quiet

defaults
        log     global
        mode    http
        option  httplog
        option  dontlognull
        retries 3
        option redispatch
        maxconn 2000
        contimeout      5000
        clitimeout      50000
        srvtimeout      50000



# reverse proxy-squid
listen  webfarm 0.0.0.0:8000
        mode http
        cookie  SERVERID insert indirect nocache
        balance roundrobin
        option httpclose
        option forwardfor header X-Client
        server  squid1 10.30.1.171:8080 check inter 2000 rise 2 fall 5
        server  squid2 10.30.1.172:8080 check inter 2000 rise 2 fall 5
        server  squid3 10.30.1.173:8080 check inter 2000 rise 2 fall 5


listen admin_stats 0.0.0.0:81
        mode http
        stats uri       /stats
        stats realm     Global\ statistics
        stats auth      username:password

        #errorloc       502     http://192.168.114.58/error502.html
        #errorfile      503     /etc/haproxy/errors/503.http
        errorfile       400     /etc/haproxy/errors/400.http
        errorfile       403     /etc/haproxy/errors/403.http
        errorfile       408     /etc/haproxy/errors/408.http
        errorfile       500     /etc/haproxy/errors/500.http
        errorfile       502     /etc/haproxy/errors/502.http
        errorfile       503     /etc/haproxy/errors/503.http
        errorfile       504     /etc/haproxy/errors/504.http

 
------------------------------ EOF ------------------------------------



.
To access the haproxy stats, use: (the "uri" defined)
http://webfarm:81/stats

Well it works, very nice, and it does backend servers check, and statistics NICE !
.

No comments: