I am running HAproxy as a container on my local ubuntu machine based on this guide:
https://hub.docker.com/_/haproxy/
I am now trying to access the stats
page in my browser with:
http://localhost:8443/haproxy?stats
http://localhost/haproxy?stats
https://localhost:8443/haproxy?stats
But all the above gives: ERR_CONNECTION_REFUSED
In my haproxy.cfg file I have:
global
maxconn 1000
ca-base /var/lib/haproxy/certs
crt-base /var/lib/haproxy/certs
tune.ssl.default-dh-param 2048
defaults
maxconn 1000
timeout connect 130s
timeout client 130s
timeout client-fin 111s
timeout server 130s
timeout server-fin 111s
timeout http-request 130s
timeout http-keep-alive 300s
# Long timeout for WebSocket connections.
timeout tunnel 1h
log global
mode http
option forwardfor
option http-server-close
option httplog
stats enable
stats uri /stats
stats realm Haproxy\ Statistics
stats auth user:password
frontend haproxy
bind :8443 ssl crt frontend/server.pem
reqadd X-Forwarded-Proto:\ http
default_backend myapp
backend myapp
server myapp localhost:9000
Also it seems the URL used in:
backend myapp
server myapp localhost:9000
does not really have an effect. If I change to :
backend myapp
server myapp 199.17.0.2:9000
I can still access myapp on localhost:9000. So what is the purpose of specifying an URL in the backend section?
I run myapp with:
docker run -d --name myapp -p 9000:9000 -p 9092:9092 myapp
Based on below suggestion/answer I run HAProxy with:
docker run -d --name my-running-haproxy -p 8443:8443 my-haproxy:1.7
And I can now access stats page on: