我正在尝试使用docker,nginx和uwsgi设置django站点:我有一个正在运行的nginx docker容器作为反向代理(称为ceca-nginx-proxy),dnsmasq并且还有一个可以通信的nginx(ceca-nginx)容器使用uwsgi容器(ceca-uwsgi),我可以使用curl(with )连接到ceca-nginx容器,并且让django站点在ceca-uwsgi容器中运行,问题是当我想通过ceca获取站点时-nginx-proxy:我的ceca-nginx-proxy错误日志中出现此错误:curl --resolve http://test.ceca.com http://172.17.0.7
ceca-nginx无法解析(5:拒绝操作),客户端:172.17.0.1,服务器:*。ceca.com,请求:“ GET / HTTP / 1.1”,主机:“ 172.17.0.8”
ceca-nginx-proxy反向代理的服务器块是:
server {
listen 80;
server_name *.ceca.com;
error_log /tmp/proxy_error_nginx.log warn;
access_log /tmp/proxy_access_nginx.log;
location / {
set $example ceca-nginx;
resolver 127.0.0.1;
proxy_pass http://$example;
}
}
Run Code Online (Sandbox Code Playgroud)
我在同一台机器上运行dnsmasq来解析/ etc / hosts中的主机名(来自docker链接容器的主机名),如下所示:
dnsmasq -q -8 /tmp/dnsmasq.log --port 53 -R -u root
Run Code Online (Sandbox Code Playgroud)
对于我在dnsmasq.log中看到的内容,主机名解析为[1],但nginx抱怨并返回“ 502 Bad Gateway”页面。如果有人可以帮助我,我将永远感激不已,如果我们见面,我会购买很多啤酒和fernet。
[1]
Jun 6 21:39:47 dnsmasq[321]: query[A] ceca-nginx from 127.0.0.1
Jun 6 21:39:48 dnsmasq[321]: /etc/hosts ceca-nginx is 172.17.0.7 …Run Code Online (Sandbox Code Playgroud)