无法访问 HAProxy 统计页面
Cannot access HAProxy stats page
我运行根据本指南将 HAproxy 作为我本地 ubuntu 机器上的容器:
https://hub.docker.com/_/haproxy/
我现在正尝试在我的浏览器中访问 stats
页面:
http://localhost:8443/haproxy?stats
http://localhost/haproxy?stats
https://localhost:8443/haproxy?stats
但以上所有给出:ERR_CONNECTION_REFUSED
在我的 haproxy.cfg 文件中我有:
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
似乎 URL 用于:
backend myapp
server myapp localhost:9000
确实没有效果。如果我改为:
backend myapp
server myapp 199.17.0.2:9000
我仍然可以在 localhost:9000 上访问 myapp。那么在后端部分指定一个URL的目的是什么?
我 运行 我的应用 与:
docker run -d --name myapp -p 9000:9000 -p 9092:9092 myapp
基于以下 suggestion/answer I 运行 HAProxy 与:
docker run -d --name my-running-haproxy -p 8443:8443 my-haproxy:1.7
我现在可以访问统计页面:
您应该将 localhost 替换为您容器的 IP 地址,因为 haproxy 运行 在您的 docker 容器内,而不是直接在您的机器上。或者您可以将 docker 容器内的 8443 端口映射到 linux 机器上的完全相同的端口。然后您就可以使用 http://localhost:8443
在浏览器中访问它
我运行根据本指南将 HAproxy 作为我本地 ubuntu 机器上的容器:
https://hub.docker.com/_/haproxy/
我现在正尝试在我的浏览器中访问 stats
页面:
http://localhost:8443/haproxy?stats
http://localhost/haproxy?stats
https://localhost:8443/haproxy?stats
但以上所有给出:ERR_CONNECTION_REFUSED
在我的 haproxy.cfg 文件中我有:
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
似乎 URL 用于:
backend myapp
server myapp localhost:9000
确实没有效果。如果我改为:
backend myapp
server myapp 199.17.0.2:9000
我仍然可以在 localhost:9000 上访问 myapp。那么在后端部分指定一个URL的目的是什么?
我 运行 我的应用 与:
docker run -d --name myapp -p 9000:9000 -p 9092:9092 myapp
基于以下 suggestion/answer I 运行 HAProxy 与:
docker run -d --name my-running-haproxy -p 8443:8443 my-haproxy:1.7
我现在可以访问统计页面:
您应该将 localhost 替换为您容器的 IP 地址,因为 haproxy 运行 在您的 docker 容器内,而不是直接在您的机器上。或者您可以将 docker 容器内的 8443 端口映射到 linux 机器上的完全相同的端口。然后您就可以使用 http://localhost:8443
在浏览器中访问它