User Tools

Site Tools


informatica:linux:haproxy

This is an old revision of the document!


Table of Contents

haproxy

balancer load balancer high availability reverse proxy

Instalacion

sudo aptitude update; sudo aptitude install haproxy

Config

En este ejemplo:

| 10.0.0.15 | Balanceador de carga (haproxy) |
| 10.0.0.4 | Servidor web 1 |
| 10.0.0.5 | Servidor web 2 |
sudo mv /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.old
sudo vim /etc/haproxy/haproxy.cfg
global
        log 127.0.0.1   local0
        log 127.0.0.1   local1 notice
        #log loghost    local0 info
        maxconn 4096
        #chroot /usr/share/haproxy
        user haproxy
        group haproxy
        daemon
        #debug
        #quiet

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

listen webfarm 10.0.0.15:80
        mode http
        balance roundrobin
        cookie SERVERID insert indirect
        option httpchk HEAD /index.html HTTP/1.0
        option  httplog
        server webA 10.0.0.4:80 cookie A check
        server webA 10.0.0.5:80 cookie B check


listen test 10.0.0.15:666
        mode tcp
        balance roundrobin
        server testA 10.0.0.4:666
        server testB 10.0.0.5:666

Ejemplo TCP (da un warning si mantenemos

Servicio

sudo /etc/init.d/haproxy restart

Probar:

wget -O - http://10.0.0.15
informatica/linux/haproxy.1340202879.txt.gz · Last modified: 2015/04/13 20:19 (external edit)