Docker Haproxy始终提供503服务不可用
我已经在Kubernetes容器上安装了Haproxy 1.8 每当我向/test发出任何请求时,我总是得到503服务不可用的响应。当我收到对/test的请求时,我想返回stats页面 以下是我的配置文件: /etc/haproxy/haproxy.cfg:Docker Haproxy始终提供503服务不可用,docker,containers,haproxy,Docker,Containers,Haproxy,我已经在Kubernetes容器上安装了Haproxy 1.8 每当我向/test发出任何请求时,我总是得到503服务不可用的响应。当我收到对/test的请求时,我想返回stats页面 以下是我的配置文件: /etc/haproxy/haproxy.cfg: global daemon maxconn 256 defaults mode http timeout connect 15000ms timeout cl
global
daemon
maxconn 256
defaults
mode http
timeout connect 15000ms
timeout client 150000ms
timeout server 150000ms
frontend stats
bind *:8404
mode http
stats enable
stats uri /stats
stats refresh 10s
frontend http-in
bind *:8083
default_backend servers
acl ar1 path -i -m sub /test
use_backend servers if ar1
backend servers
mode http
server server1 10.1.0.46:8404/stats maxconn 32
# 10.1.0.46 is my container IP
我可以通过以下方式访问/stats
页面:
curl -ik http://10.1.0.46:8404/stats
但当我这样做的时候:
curl -ik http://10.1.0.46:8083/test
我总是得到以下回应:
HTTP/1.0 503 Service Unavailable
Cache-Control: no-cache
Content-Type: text/html
<html><body><h1>503 Service Unavailable</h1>
No server is available to handle this request.
</body></html>
然后使用以下命令重新启动它:
haproxy -f haproxy.cfg -p /var/run/haproxy.pid -sf $(cat /var/run/haproxy.pid)
以下是netstat-anlp的输出:
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:5000 0.0.0.0:* LISTEN 54/python3.5
tcp 0 0 0.0.0.0:8083 0.0.0.0:* LISTEN 802/haproxy
tcp 0 0 0.0.0.0:8404 0.0.0.0:* LISTEN 802/haproxy
tcp 0 0 10.1.0.46:8404 10.0.15.225:20647 TIME_WAIT -
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node PID/Program name Path
以下是ps-eaf
的输出:
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 Jul22 ? 00:00:00 /bin/sh -c /bin/bash -x startup_script.sh
root 6 1 0 Jul22 ? 00:00:00 /bin/bash -x startup_script.sh
root 54 6 0 Jul22 ? 00:00:09 /usr/local/bin/python3.5 /usr/local/bin/gunicorn --bind 0.0.0.0:5000 runner:app?
root 57 54 0 Jul22 ? 00:02:50 /usr/local/bin/python3.5 /usr/local/bin/gunicorn --bind 0.0.0.0:5000 runner:app?
root 61 0 0 Jul22 pts/0 00:00:00 bash
root 739 0 0 07:02 pts/1 00:00:00 bash
root 802 1 0 08:09 ? 00:00:00 haproxy -f haproxy.cfg -p /var/run/haproxy.pid -sf 793
root 804 739 0 08:10 pts/1 00:00:00 ps -eaf
为什么503总是不可用?当2.2.x已经存在时,为什么要使用HAProxy 1.8 您需要在后端采用无法在服务器级别设置的路径
backend servers
mode http
http-request set-path /stats
server server1 10.1.0.46:8404 maxconn 32
# 10.1.0.46 is my container IP
pod中的所有容器都共享网络名称空间,因此您应该能够在后端使用127.0.0.1谢谢。如果我的后端服务器位于另一个容器上,具有另一个IP地址,如10.1.0.47,那么设置的路径应该是什么?当目标上的路径相同时,该路径独立于IP
backend servers
mode http
http-request set-path /stats
server server1 10.1.0.46:8404 maxconn 32
# 10.1.0.46 is my container IP