mercredi 22 août 2012

Comment configurer un HAProxy pour rediriger les flux selon le Host ?

Pour répondre à la problématique de faire répondre un JBoss et un Apache sur le même port 80, j'ai utilisé un proxy.
Le proxy écoute sur le port 80 et selon le paterne de l'URL, il route le flux vers le port 8000 d'apache ou le port 8080 de JBoss.
Le proxy que j'ai utilisé, est HAProxy. (un produit francais maintenu par Willy TARREAU).

Sous debian, j'ai installé le produit:
$apt-get install haproxy

Je me suis rendu dans le repertoire:
/etc/haproxy

J'ai édité le fichier haproxy.cfg et j'ai ajouté la configuration suivante:


frontend http
        bind 0.0.0.0:80
        default_backend jboss
        # NAT static host names and static paths in other hostnames to a different backend
        acl host_static hdr_beg(host) -i static.
        acl url_static  path_beg         /static
        use_backend apache if host_static or url_static

backend jboss
        balance roundrobin
        server  qa1 127.0.0.1:8080
        #server  qa2 10.177.1.45:80

backend apache
        balance roundrobin
        server  media1 127.0.0.1:8000

Enjoy.

1 commentaire:

  1. Why I Don't Pay my Visit To Slots in Las Vegas, Nevada
    This isn't even 광양 출장마사지 my first experience gambling at 서울특별 출장마사지 a casino. The casino floor 구미 출장안마 isn't as bright 다파벳 as the hotel in 제주 출장샵 Vegas.

    RépondreSupprimer