可以访问 haproxy 负载均衡器后面的特定机器进行健康检查

Can access a specific machine behind a haproxy loadbalancer for health check

我有一个网站,由 haproxy 负载均衡器后面的几台机器提供服务。现在它使用基于 cookie 的粘性会话。我正在使用 uptimerobot 检查机器的运行状况,但我无法将其配置为使用 cookie,并且我不希望负载均衡器成为互联网的唯一开放点。

有没有办法配置负载平衡器以通过 url 参数访问机器?

有办法,但不可取。在配置中,创建重复的后端块和基于 url_param 的 ACL,以根据 URL 参数将请求路由到特定服务器。

示例:

frontend fe
    bind x.x.x.x:80
    bind x.x.x.x:443 ssl crt.. blah
    ...
    default_backend www

    acl is_healthchk_s1 url_param(CHECK) -i s1
    acl is_healthchk_s2 url_param(CHECK) -i s2
    acl is_healthchk_sn url_param(CHECK) -i sn

    use_backend be_healthchk_s1 if is_healthchk_s1
    use_backend be_healthchk_s2 if is_healthchk_s2
    use_backend be_healthchk_sn if is_healthchk_sn

backend www
    server s1 x.x.x.x:8080 check
    server s2 x.x.x.x:8080 check
    server sn x.x.x.x:8080 check

backend be_healthchk_s1
    server s1 x.x.x.x:8080 check
backend be_healthchk_s2
    server s2 x.x.x.x:8080 check
backend be_healthchk_s3
    server s3 x.x.x.x:8080 check

因此,您的正常运行时间机器人可以改为检查这些:

  • domain.com/?CHECK=s1
  • domain.com/?CHECK=s2
  • domain.com/?CHECK=sn