[英]docker container: curl: (7) Failed to connect to 172.17.0.1 port 4000: No route to host
I have graphql
server running on the main machine on 4000 port我在 4000 端口的主机上运行了graphql
服务器
curl from the machine works well and I got what I expect:机器上的 curl 效果很好,我得到了我的期望:
curl -X POST -H "Content-Type: application/json" --data '{ "query": "{ me { _id } }" }' http://localhost:4000/graphq
when I do curl on container:当我在容器上卷曲时:
curl http://172.17.0.1
I got:我有:
<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.16.1</center>
</body>
</html>
It shows me that I can reach ngnix
from container and it indicates for me that I can reach my machine from the container.它告诉我我可以从容器到达ngnix
并且它告诉我我可以从容器到达我的机器。
but when I curl form container:但是当我卷曲形成容器时:
curl -X POST -H "Content-Type: application/json" --data '{ "query": "{ me { _id } }" }' http://172.17.0.1:4000/graphql
I got:我有:
curl: (7) Failed to connect to 172.17.0.1 port 4000: No route to host
I think you have to configure Nginx for public access because the docker uses a special network like it does have different network range you have to specify the network range in the Nginx server.我认为您必须将 Nginx 配置为公共访问,因为 docker 使用特殊网络,就像它确实具有不同的网络范围一样,您必须在 Nginx 服务器中指定网络范围。
please refer the following link: https://docs.nginx.com/nginx/admin-guide/security-controls/controlling-access-proxied-tcp/请参考以下链接: https : //docs.nginx.com/nginx/admin-guide/security-controls/controlling-access-proxied-tcp/
https://www.cyberciti.biz/faq/linux-unix-nginx-access-control-howto/ https://www.cyberciti.biz/faq/linux-unix-nginx-access-control-howto/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.