0

Haproxy experts,

I'm unable to get haproxy stats page to work with TCP mode for the backends.

global log 127.0.0.1 local2 chroot /var/lib/haproxy pidfile /var/run/haproxy.pid maxconn 4000 user haproxy group haproxy daemon stats socket /var/lib/haproxy/stats defaults mode tcp log global option httplog option dontlognull option http-server-close option forwardfor except 127.0.0.0/8 option redispatch retries 3 timeout http-request 10s timeout queue 1m timeout connect 10s timeout client 1m timeout server 1m timeout http-keep-alive 10s timeout check 10s maxconn 3000 stats enable stats hide-version stats refresh 30s stats show-node stats auth admin:xxxxxxxxxxxxxxxxx stats uri /haproxy?stats frontend main listen stats bind *:5000 mode tcp default_backend app backend app balance roundrobin #backends server server1 xxx.xxx.xxx.xxx:10222 check server server2 xxx.xxx.xxx.xxx:34013 check 
3
  • Please don't post screenshots of text that you could copy&paste. Just copy&paste it into the question, you are just making it harder for people to extract information from it. Commented Feb 9, 2023 at 10:37
  • You can use the text formatting tools. Or just paste it as it is, someone will format it properly for you. Commented Feb 9, 2023 at 11:00
  • Whoever wants to get help makes it easy for a potential helper to give a help. And it is very inconvenient to be required to go via links to pictures to read text from them, the text which should have been embedded into the question as text. So personally I won't bother looking at your pictures, and base all my help on what I see in the question directly. // That said, haproxy stats require HTTP mode. So yes, it is not working in TCP, this is how it is intended. If you don't have HTTP listeners you need to create one just for the stats. It will list TCP things too on the stats page. Commented Feb 9, 2023 at 17:17

1 Answer 1

0

HAproxy requires HTTP mode listener for the stats page, period. If you want stats, you need to have or create one.

This could be implemented with simple listen section without any actual backends, if you don't have any HTTP backends or if you want stats page to not to be bound to any existing HTTP listeners.

Remove all stats-related lines from defaults, and create an individual listen section just for the stats, where you put all those lines:

listen stats mode http bind *:8080 stats enable stats hide-version stats refresh 30s stats show-node stats auth admin:xxxxxxxxxxxxxxxxx stats uri /haproxy?stats 

Also remove your listen stats line just after frontend main. What it does currently is terminating "frontend" section main (which happens to be empty and only has defaults), creating new "listen" section stats and applying the following few lines to it. I am sure this is not what you want.

1
  • You're the best man. :) Thanks. It worked like charm. Kudus Commented Feb 10, 2023 at 23:06

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.