How to configure Amazon ELB ping target for haproxy

amazon-elbhaproxy

I'm trying to setup Amazon ELB to route requests to couple of haproxy servers. ELB requires a ping target to the respective servers for health check. It uses index.html at port 80. I'm struggling to configure an index.html in haproxy. Here's my haproxy configuration :


global
    log         127.0.0.1 local2
    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        haproxy
    group       haproxy
    daemon

defaults
    mode        http
    option      dontlognull
    option      httpclose
    option      httplog
    option      forwardfor
    option      redispatch
    option httpchk HEAD /index.html HTTP/1.0
    timeout connect 10000 # default 10 second time out if a backend is not found
    timeout client 300000
    timeout server 300000
    maxconn     60000
    retries     3

#
# Host HA-Proxy's web stats on Port 81.
listen stats :1936
    mode http
    stats enable
    stats hide-version
    stats realm Haproxy\ Statistics
    stats uri /
    stats auth Username:Password

frontend  main *:80
    log 127.0.0.1 local2
    capture request  header         X-Forwarded-For      len 500
    capture response header         X-Query-Result       len 100
    acl url_webapp                  path_beg -i /supporttoolbar
    acl url_jsonproxy               path_beg -i /proxy

backend webapp
    balance     roundrobin
    server      webapp1 10.100.86.xxx:80 check
backend jsonproxy
    balance     roundrobin
    server      webapp1 10.100.86.xxx:80 check

The html page is located under /var/www/html/

I tried adding option httpchk HEAD /index.html HTTP/1.0 under defaults section, but didn't work.

Any pointers will be appreciated.

Thanks

Best Answer

Please have a look at this gist. It basically describes/configures what you require:

# Create a monitorable URI which returns a 200 if at least 1 server is up.
# This could be used by Traverse/Nagios to detect if a whole server set is down.
acl servers_down nbsrv(servers) lt 1
monitor-uri /haproxy?monitor
monitor fail if