首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >HAProxy运行状况检查

HAProxy运行状况检查
EN

Stack Overflow用户
提问于 2014-05-07 15:57:58
回答 3查看 13.6K关注 0票数 10

我当前的设置中有2个HAProxies配置了keepalived for High Availability,这2个代理充当虚拟with服务的反向代理和负载均衡器。我知道HAProxy可以检查其后端的健康状况(我已经对此进行了配置),但我的问题是另一回事。

在我的公司有一个F5大IP负载均衡器,它是第一道防线,它会在需要时将请求重定向到我的HAProxies。

我需要知道是否有一种方法可以让我的F5大IP检查HAProxies前端的健康状况,以便在代理启动时不会丢失任何请求。

谢谢

EN

回答 3

Stack Overflow用户

发布于 2016-08-03 18:24:04

以前有一个mode health选项,但在最近的版本中,最简单的方法是在给定的端口上使用monitor-uri

代码语言:javascript
复制
listen health_check_http_url
    bind :8888
    mode http
    monitor-uri /healthz
    option      dontlognull

您可以在前端使用monitor-uri,也可以通过ACL选择它,但端口版本非常清晰和简单。

https://cbonte.github.io/haproxy-dconv/1.6/configuration.html#4.2-mode

https://cbonte.github.io/haproxy-dconv/1.6/configuration.html#4.2-monitor-uri

票数 13
EN

Stack Overflow用户

发布于 2014-05-10 04:31:14

HAProxy Reference Manual

代码语言:javascript
复制
Health-checking mode
--------------------
This mode provides a way for external components to check the proxy's health.
It is meant to be used with intelligent load-balancers which can use send/expect
scripts to check for all of their servers' availability. This one simply accepts
the connection, returns the word 'OK' and closes it. If the 'option httpchk' is
set, then the reply will be 'HTTP/1.0 200 OK' with no data, so that it can be
tested from a tool which supports HTTP health-checks. To enable it, simply
specify 'health' as the working mode :

Example :
---------
    # simple response : 'OK'
    listen health_check 0.0.0.0:60000
        mode health

    # HTTP response : 'HTTP/1.0 200 OK'
    listen http_health_check 0.0.0.0:60001
        mode health
        option httpchk
票数 4
EN

Stack Overflow用户

发布于 2019-04-01 21:04:34

从HAProxy文档

代码语言:javascript
复制
Example:
frontend www
    mode http
    acl site_dead nbsrv(dynamic) lt 2
    acl site_dead nbsrv(static)  lt 2
    monitor-uri   /site_alive
    monitor fail  if site_dead

查看参考文档。

http://cbonte.github.io/haproxy-dconv/1.8/configuration.html#4.2-monitor-uri

代码语言:javascript
复制
<uri>     is the exact URI which we want to intercept to return HAProxy's
          health status instead of forwarding the request.

When an HTTP request referencing <uri> will be received on a frontend,
HAProxy will not forward it nor log it, but instead will return either
"HTTP/1.0 200 OK" or "HTTP/1.0 503 Service unavailable", depending on failure
conditions defined with "monitor fail". This is normally enough for any
front-end HTTP probe to detect that the service is UP and running without
forwarding the request to a backend server. Note that the HTTP method, the
version and all headers are ignored, but the request must at least be valid
at the HTTP level. This keyword may only be used with an HTTP-mode frontend.

Monitor requests are processed very early. It is not possible to block nor
divert them using ACLs. They cannot be logged either, and it is the intended
purpose. They are only used to report HAProxy's health to an upper component,
nothing more. However, it is possible to add any number of conditions using
"monitor fail" and ACLs so that the result can be adjusted to whatever check
can be imagined (most often the number of available servers in a backend).
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23512029

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档