检查失败后 HAProxy 无法恢复

Mic*_*ten 5 proxy haproxy docker

全部,

我遇到了 HAProxy 在后端服务器重新启动后无法恢复的问题。我没有使用代理进行负载平衡,而是将不同的 URL 定向到不同的服务器(Web 和 Web 服务)以避免跨域问题。代理工作正常,直到第一次检查失败,但一旦备份,HAProxy 就永远不会恢复转发到它。代理在 docker 容器 ( https://registry.hub.docker.com/u/dockerfile/haproxy/dockerfile/ ) 内运行,并且应该运行 HAProxy 1.5.3。

haproxy.cfg

global
    log         127.0.0.1 local0
    log         127.0.0.1 local1 notice
    user        haproxy
    group       haproxy

defaults
    mode        http
    log         global
    option      dontlognull
    option      httpclose
    option      httplog
    option      forwardfor
    option      persist
    option      redispatch
    option      http-server-close
    contimeout 5000
    clitimeout 50000
    srvtimeout 50000
    maxconn     60000
    retries     3
    errorfile 400 /etc/haproxy/errors/400.http
    errorfile 403 /etc/haproxy/errors/403.http
    errorfile 408 /etc/haproxy/errors/408.http
    errorfile 500 /etc/haproxy/errors/500.http
    errorfile 502 /etc/haproxy/errors/502.http
    errorfile 503 /etc/haproxy/errors/503.http
    errorfile 504 /etc/haproxy/errors/504.http
    stats enable
    stats uri /haproxy-stats

frontend http-in
    bind *:80

    default_backend       server1
    acl url_server1       path_beg -i     /server1
    acl url_server2       path_beg -i     /services/server2
    use_backend server1   if url_server1
    use_backend server2   if url_server2

backend server1
    balance roundrobin
    option httpchk GET /server1/content/
    server server1 server1:8080 check inter 10s rise 1 fall 5

backend server2
    balance roundrobin
    option httpchk GET /services
    server server2 server2:8181 check inter 5s rise 1
Run Code Online (Sandbox Code Playgroud)

在 HAProxy 的日志中,我看到以下错误消息:

[WARNING] 040/210248 (1) : Server server1/server1 is DOWN, reason: Layer4 connection problem, info: "Connection refused", check duration: 0ms. 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
[ALERT] 040/210248 (1) : backend 'server1' has no server available!
Run Code Online (Sandbox Code Playgroud)

在浏览器中我看到:

503 Service Unavailable
No server is available to handle this request.
Run Code Online (Sandbox Code Playgroud)

一旦我重新启动服务器,我就再也看不到一条日志消息表明 HAProxy 已确定它已恢复,并且我仍然在浏览器中收到 503 错误,即使我可以点击 server1:8080 并看到该站点已备份。

ben*_*lor -1

我偶然发现了完全相同的问题,我认为这是设计使然。HAProxy 有一个负责此行为的属性fall

fall <count>  
   The "fall" parameter states that a server will be considered as dead after
   <count> consecutive unsuccessful health checks. This value defaults to 3 if
   unspecified. See also the "check", "inter" and "rise" parameters.
Run Code Online (Sandbox Code Playgroud)

我不知道如何复活一个死去的个体。我什至尝试了这个问题中提到的交互式控制台