嗨,我正在使用 haproxy 来平衡我的 https 连接。我想做主动健康检查,但它们似乎不起作用。欢迎任何有关如何正确编写以下内容的提示。我让它们在 http 端口 80 连接上正常工作。
frontend incoming_https
bind *:443
mode tcp
default_backend web_https
backend web_https
mode tcp
option httpchk GET / HTTP/1.1\r\nHost:\ https://www.mysite.com
server web-0 xxx.xxx.xxx.xxx:443 check inter 5000 port 443
最佳答案
是的,您可以在 tcp 模式下使用选项 httpchk。以下是在 ssl 后面的页面上搜索字符串的必要选项:
mode tcp
option httpchk GET /<URI>
http-check expect string <STRING\ WITH\ SPACES\ ESCAPED>
server <YOUR_SERVER_FQDN>:443 <YOUR_SERVER_IP>:443 check ssl verify none
例如,要检查 login.html 页面的“用户名”字符串:
mode tcp
option httpchk GET /login.html
http-check expect string User\ Name
server www.example.com:443 192.168.1.1:443 check ssl verify none
请注意,“check ssl verify none”是必需的,并且搜索字符串中的任何空格都必须用\转义。
关于load-balancing - haproxy https 健康检查,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16719388/