Docker nginx反向代理提供“502 Bad Gateway”
我正在尝试使用nginx工作的docker容器作为其他docker容器的反向代理,并且我继续在除了基本位置’/’之外的其他位置上获得“Bad Gateway”.
我有以下服务器块:
server {
listen 80;
location / {
proxy_pass "http://game2048:8080";
}
location /game {
proxy_pass "http://game:9999";
}
}
它适用于http:// localhost,但不适用于http:// localhost / game,它在浏览器中提供“Bad Gateway”,并在nginx容器上提供:
[error] 7#7: *6 connect() failed (111: Connection refused)
while connecting to upstream, client: 172.17.0.1, server: ,
request: "GET /game HTTP/1.1", upstream: "http://172.17.0.4:9999/game",
host: "localhost"
我使用官方的nginx docker镜像并在其上放置我自己的配置.您可以在此处测试并查看所有详细信息:https://github.com/jollege/ngprox1
任何想法出了什么问题?
注意:我在docker主机上设置了本地主机名条目以匹配这些名称:
127.0.1.1 game2048
127.0.1.1 game