46

I can't figure out how to set up stats for HAProxy.

This is my configuration:

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

As far as I understand the manual there should be a stats page available via http://mysite/haproxy?stats. What am I missing?

EDIT: I can access the stats with socat but not with a web browser.

Jan Deinhard
  • 2,363
  • 5
  • 26
  • 33

4 Answers4

71

That is not correct. There would be a stats page on http://yoursite.com:1935/haproxy?stats

To overcome this add another listener-

listen stats :1936
    mode http
    stats enable
    stats hide-version
    stats realm Haproxy\ Statistics
    stats uri /
    stats auth Username:Password

Then go to http://yoursite.com:1936/ and login.

Make sure your firewall isn't blocking this request.

eric
  • 103
  • 2
Chris
  • 1,269
  • 2
  • 17
  • 34
7

This did it for me:

listen stats
    bind :9000

or

listen stats
    bind 10.100.86.150:9000
Tadej
  • 371
  • 5
  • 5
6

In new versions of haproxy (>1.6) you have to set the mode to http instead of tcp (default) to config : 'stats' statement ignored for frontend 'http-in' as it requires HTTP mode.

zypro
  • 163
  • 1
  • 5
0

you need to add script like bind *:port for example bind*:80 or you can replace the star symbol with your ip public or ip from machine are installed.

suggestion from me, you can move stats script to one frontend or add one frontend to access stats privately.