Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

load balancing - Enable stats uri page in HAProxy tcp mode

Below is my haxproxy configuration. I am trying to enable stats page so that I can see the status of the servers. But after validating the file, getting a warning message as below and stats page is not shown after hitting the configured uri.

'stats' statement ignored for frontend 'http-in' as it requires HTTP mode

I am using haproxy version 1.8.x.

global
   log /dev/log local0
   log /dev/log local1 notice
   user haproxy
   group haproxy
   daemon

defaults
   log  global
   mode tcp
   option   tcplog
   timeout connect 120s
   timeout client  300s
   timeout server  180s

frontend http-in        
     bind *:443
     stats enable
     stats refresh 10s
     stats uri /haproxy?stats
     default_backend servers


backend servers
    
     balance    roundrobin
     server sec-server1 192.68.29.230:8080 check
     server sec-server2 192.68.29.229:8080 check

Please assist. can we not see the stats page in tcp mode?

question from:https://stackoverflow.com/questions/65951553/enable-stats-uri-page-in-haproxy-tcp-mode

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Add the below things and try

global

global
    # turn on stats unix socket
    stats socket /var/lib/haproxy/stats mode 666 level admin
    server-state-file /var/lib/haproxy/haproxy.state

defaults

defaults
    default-server init-addr last,libc,none
    load-server-state-from-file global

frontend

frontend  http-in
    bind *:443

    option http-server-close
    option forwardfor
    http-request add-header X-Forwarded-Proto https
    http-request add-header X-Forwarded-Port 1443


    default_backend             servers

    stats uri                   /hap?_stats
    stats auth                  haadm:username@pwd
    stats hide-version
    stats show-node

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...