I'm using HAProxy 1.6.4 and want to enable the stats. (/haproxy?stats)
Here is my cfg:
global
log 127.0.0.1 local2
daemon
maxconn 256
defaults
log global
timeout connect 5000
timeout client 10000
timeout server 10000
frontend http-in
bind *:8080
default_backend testb
backend testb
balance roundrobin
server s1 123.456.789.0:443 maxconn 32
server s2 123.456.789.1:443 maxconn 32
listen statistics
bind *:8080
mode http
stats enable
If I run statistics on other port than 8080 it works, but how can I run it on the same port as my frontend (8080), which is running in the default mode tcp
?
You can do it by redirecting to your self and using access list like this:
When going to your server with
www
, it takes you to the web server. But usingstat
, it redirects you from your input port8080
to1936
whee stat is runningThis is just an educated guess. You can't serve the
stats
page intcp
mode because it's proxying at layer4. In this mode, haproxy only knows IPs and ports from incoming packets and routes it accordingly based on defined rules.Unlike
http
mode (layer7), it has more info to work on like HTTP headers wherepath
is available and use it to know when to serve the/haproxy?stats
page.