HAProxy, health checking multiple servers with different host names

Solution 1:

defaults
log global
retries 2
timeout connect 3000
timeout server 5000
timeout client 5000

listen any-name-1
bind IP-Address:port
mode tcp or http
option user-check user haproxy_check
balance roundrobin
server hostname IpAddress:port check
server hostname  IpAddress:port check
listen any-name-2
bind IP-Address:port
mode tcp or http
option user-check user haproxy_check
balance roundrobin
server hostname IpAddress:port check
server hostanme  IpAddress:port check

listen any-name-3
bind IP-Address:port
mode tcp or http
option user-check user haproxy_check
balance roundrobin
server hostname IpAddress:port check
server hostname  IpAddress:port check

listen any-name-4
bind IP-Address:port
mode tcp or http
option user-check user haproxy_check
balance roundrobin
server hostname IpAddress:port check
server hostname  IpAddress:port check

listen any-name-5
bind IP-Address:port
mode tcp or http
option user-check user haproxy_check
balance roundrobin
server hostname IpAddress:port check
server hostname  IpAddress:port check

listen haproxyadmin
bind HAproxyServerIP:HaproxyPort
mode http
stats enable
stats uri /haproxy
stats realm Strictly\ Private
stats auth username:password

Solution 2:

Update: In the case you described, you need HTTP/1.1 checks which require the host name hardcoded. Given the documentation of version 1.5, there doesn't seem to be a way to avoid this unless you can afford to drop the http checks (which of course is generally not recommended).

Original answer: While I am not familiar with the 1.5 changes of haproxy, what I would do in 1.4 (and I'm fairly sure it still applies in 1.5) is the following. Note that the frontend/backend separation is just a personal convenience and you could just use listen.

defaults
    mode http
    option  httplog
    timeout connect  5000
    timeout client  10000
    timeout server  10000

frontend inbound
    bind 127.0.0.1:8000
    default_backend webservers

backend webservers
    option forwardfor
    option httpchk HEAD / HTTP/1.0
    http-send-name-header Host
    server google www.google.com:80 check inter 5000 fall 3 rise 2
    server bing www.bing.com:80 check inter 5000 fall 3 rise 2

And the result:

$ curl -i localhost:8000
HTTP/1.1 301 Moved Permanently
Cache-Control: no-cache
Content-Length: 0
Location: http://www.bing.com/
Server: Microsoft-IIS/8.0
P3P: CP="NON UNI COM NAV STA LOC CURa DEVa PSAa PSDa OUR IND"
Set-Cookie: _HOP=I=1&TS=1399981378; path=/
Edge-control: no-store
X-MSEdge-Ref: Ref A: 26CEE14531BF45EFAC91FAC3D1945EDF Ref B: 42CE8D142D427C30F7851B56F38837A6 Ref C: Tue May 13 04:42:58 2014 PST
Date: Tue, 13 May 2014 11:42:57 GMT

$ curl -i localhost:8000
HTTP/1.1 301 Moved Permanently
Location: http://www.google.com/
Content-Type: text/html; charset=UTF-8
X-Content-Type-Options: nosniff
Date: Tue, 13 May 2014 11:43:00 GMT
Expires: Thu, 12 Jun 2014 11:43:00 GMT
Cache-Control: public, max-age=2592000
Server: sffe
Content-Length: 219
X-XSS-Protection: 1; mode=block
Alternate-Protocol: 80:quic

<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
$