我正在尝试摆脱配置中已弃用的 Docker 链接。剩下的就是在我重新创建容器时摆脱那些 Bad Gateway
nginx 反向代理错误。
注意:我在桥接模式下使用 Docker 网络。 ( docker network create nettest
)
我在 nginx 中使用以下配置片段:
location / {
resolver 127.0.0.1 valid=30s;
set $backend "http://confluence:8090";
proxy_pass $backend;
- 我在名为 --- 的 Docker 网络上启动了一个主机名为
nettest
confluence
容器。 - 然后我在网络上启动了 nginx 容器
nettest
。 - 我可以从 nginx 容器内部 ping
confluence
confluence
列在 nginx 容器的/etc/hosts
文件中- nginx日志说
send() failed (111: Connection refused) while resolving, resolver: 127.0.0.1:53
- 我尝试了 docker network default dns resolver
127.0.0.11
from/etc/resol.conf
- nginx日志说
confluence could not be resolved (3: Host not found)
任何人都知道如何使用 Docker Networks 配置 nginx 解析器,或者如何强制 Nginx 正确解析 Docker 网络主机名的替代方法?
原文由 blacklabelops 发布,翻译遵循 CC BY-SA 4.0 许可协议
首先,您应该在
127.0.0.11
使用 Docker 嵌入式 DNS 服务器。您的问题可能是由以下其中一项引起的:
有关解决方案,请参阅 https://stackoverflow.com/a/35516395/1529493 。
基本上是这样的:
这可能不再是 Docker 1.11 的问题:
resolver
配置指令。 In my case I had in theserver
blockresolver 8.8.8.8 8.8.4.4;
from Mozilla’s SSL Configuration Generator , which was overriding theresolver 127.0.0.11;
in thehttp
block.这让我挠了很久……