下面的配置文件按预期工作,但对实际的同一个代理服务器进行重复的健康检查,我该如何避免这种重复的健康检查?(我仍然想做健康检查,但不进行重复的健康检查)
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
您将在后端进行健康检查,现在您可以对多个前端使用同一个后端。