如何为 HAProxy 设置统计信息?

Jan*_*ard 42 load-balancing haproxy

我不知道如何为 HAProxy 设置统计信息。

这是我的配置:

global
    log 127.0.0.1 local0
    log 127.0.0.1 local1 notice
    daemon
    #debug
    user haproxy
    group haproxy
    maxconn 4096

    stats socket /tmp/haproxy

defaults
    log global
    mode tcp
    option tcplog
    option dontlognull
    option redispatch
    option clitcpka
    option srvtcpka
    option tcpka
    retries 3
    maxconn 2000
    contimeout 10000
    clitimeout 50000
    srvtimeout 50000

    stats enable
    stats hide-version
    stats scope .
    stats realm Haproxy\ Statistics
    stats uri /haproxy?stats
    stats auth xxxxx:xxxxx

    option contstats

listen rtmp :1935
    mode tcp
    balance roundrobin

    server s1 xxx.xxx.xxx.xxx:1935 check
    server s2 xxx.xxx.xxx.xxx:1935 check
Run Code Online (Sandbox Code Playgroud)

据我了解手册应该有一个统计页面可通过http://mysite/haproxy?stats 获得。我错过了什么?

编辑:我可以使用 socat 访问统计信息,但不能使用网络浏览器访问。

Chr*_*ris 68

那是不正确的。http://yoursite.com:1935/haproxy?stats上会有一个统计页面

为了克服这个问题,请添加另一个听众-

listen stats :1936
    mode http
    stats enable
    stats hide-version
    stats realm Haproxy\ Statistics
    stats uri /
    stats auth Username:Password
Run Code Online (Sandbox Code Playgroud)

然后访问http://yoursite.com:1936/并登录。

确保您的防火墙没有阻止此请求。


ttt*_*ttt 7

这为我做到了:

listen stats
    bind :9000
Run Code Online (Sandbox Code Playgroud)

或者

listen stats
    bind 10.100.86.150:9000
Run Code Online (Sandbox Code Playgroud)


zyp*_*pro 5

在 haproxy (>1.6) 的新版本中,您必须将模式设置为http而不是tcp(默认)为config : 'stats' statement ignored for frontend 'http-in' as it requires HTTP mode.