Hosting, Open Source

Apache Virtual Hosts & HAProxy

When checking pages with option httpchk against an apache server with virtual hosts setup, you have to remember to put the full domain to what you want to check. This is because if you don’t have the domain, Apache won’t know which virtual host to sent the request to, and you could get pages that are UP showing DOWN, or worse, pages that are DOWN showing UP.

Another thing to remember is using option forwardfor, which passes the domain along with the request, so it will go to the right virtual host.

Also, check out this video by 37signals about how they use HAProxy and maxconn 1 to get around mongrel’s blocking requests.

Nuts and Bolts: HAProxy

listen mysite 0.0.0.0:80
        mode http
        option forwardfor
        balance roundrobin
        option httpchk http://full.domain.name/check.htm
        server app1 192.168.1.1:80 check inter 2000 rise 2 fall 5 maxconn 1
        server app2 192.168.1.2:80 check inter 2000 rise 2 fall 5 maxconn 1

speak up

Add your comment below, or trackback from your own site.

Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*Required Fields