我试图设置Amazon ELB来将请求路由到haproxy服务器。 ELB需要一个ping对象到相应的服务器进行健康检查。 它在端口80使用index.html。我努力在haproxy中configurationindex.html。 这是我的haproxyconfiguration:
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
html页面位于/ var / www / html /
我试着在defaults部分添加选项httpchk HEAD /index.html HTTP / 1.0 ,但是没有工作。
任何指针将不胜感激。
谢谢
请看这个要点 。 它基本上描述/configuration你所需要的:
# 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
我通过在Haproxyconfiguration文件中添加以下条目find了一个备用。
defaults mode http option dontlognull option httpclose option httplog option forwardfor option redispatch timeout connect 10000 # default 10 second time out if a backend is not found timeout client 300000 timeout server 300000 monitor-uri /index.html maxconn 60000 retries 3
条目monitor-uri /index.html条目做了窍门。 Haproxy有这个内置的健康检查,如果服务启动,返回200。 我只是嘲笑它使用Amazon ELB认可的/index.html。