检查Haproxy中真正的同一台服务器?

分享于 

2分钟阅读

互联网

 

问题:

以下配置文件工作正常,但对真正的代理服务器执行重复的健康检查,如何避免这种重复的健康检查? ( 我仍然希望进行健康检查,但不重复健康检查)


global


 external-check


defaults


 option httplog


 log 127.0.0.1:514 user


 timeout connect 5000s


 timeout client 5000s


 timeout server 5000s


#Close the using connection when backend server marked as down


listen main-proxy1


 bind 127.0.0.1:8079


 mode http


 option external-check


 external-check command/checker


 balance static-rr


 server proxy1 127.0.0.1:9999 check on-marked-down shutdown-sessions on-marked-up shutdown-backup-sessions


#Don't close the using connection when backend server marked as down


listen main-proxy2


 bind 127.0.0.1:8080


 mode http


 option external-check


 external-check command/checker


 balance static-rr


 server proxy2 127.0.0.1:9999 check




回答 1:

你可以使用 track 指令来跟踪其他服务器的状态。 在你的情况下,第二个 server 行是:


server proxy2 127.0.0.1:9999 track main-proxy1/proxy1




回答 2:

我认为解决这个问题最简单的方法是定义前端和后端:

例如:


frontend www.mysite.com


 bind 10.0.0.3:80


 bind 10.0.0.3:443 ssl crt/etc/ssl/certs/mysite.pem


 http-request redirect scheme https unless { ssl_fc }


 use_backend api_servers if { path_beg/api/}


 default_backend web_servers



backend web_servers


 balance roundrobin


 cookie SERVERUSED insert indirect nocache


 option httpchk HEAD/


 default-server check maxconn 20


 server server1 10.0.1.3:80 cookie server1


 server server2 10.0.1.4:80 cookie server2



你将在后面拥有 healthcheck,现在你可以在多个前端中使用相同的后端了。



Server  Haproxy  
相关文章