curl:(7)无法连接到localhost端口8090:连接被拒绝 [英] curl: (7) Failed to connect to localhost port 8090: Connection refused

查看:42107
本文介绍了curl:(7)无法连接到localhost端口8090:连接被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要帮助。一直在尝试解决这个问题,看不到答案,或者我没有遇到任何问题。

Need help. Have been trying for a solution to this issue and could not see an answer or rather I have not come across any.

我有一个装有NGINX的docker容器,反向代理。 Docker for Windows版本1.12.5(9503)。

I have a docker container with NGINX, acting as a reverse proxy. Docker for Windows version 1.12.5(9503).

upstream mysite {
    server 127.0.0.1:8090;
    #server localhost:8090; (have also tried this option)
}

server {
    listen 0.0.0.0:80;
    server_name  localhost;

    location / {
        proxy_pass http://mysite;
    }
}

在上面的代码中localhost:8090是一个url在我的主机上的IIS上托管的网站。当我访问NGINX上的URL时,会收到以下错误

In the above code localhost:8090 is a url of a website that is hosted on IIS on my host machine. When I access the url on NGINX, I get the following error

2016/12/27 08:11:57 [error] 6#6: *4 no live upstreams while connecting to upstream, client: 172.17.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "http://googlesite/", host: "localhost"
172.17.0.1 - - [27/Dec/2016:08:11:57 +0000] "GET / HTTP/1.1" 502 173 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:50.0) Gecko/20100101 Firefox/50.0" "-"






尝试访问主机上的网址


Tried to access the url on the host machine


(简单的HTML网站, html,托管在IIS上,授予所有人的匿名访问权限。)

(simple HTML site, single page with only simple html, hosted on IIS with anonymous access granted to all.)



curl localhost:8090

获取以下错误:

curl: (7) Failed to connect to localhost port 8090: Connection refused

新的Docker和NGINX。想知道是否可以访问主机上的URL?如果是,那么我错了。

Am new to Docker and NGINX. Would like to know if it is possible to access urls on the host machine? If Yes, then where am I wrong.

如果我使用google.co.in而不是127.0.0.1:8090,同样的配置可以工作。

The same configuration works, if I use google.co.in instead of 127.0.0.1:8090.

感谢。

推荐答案

在Docker容器中, localhost 127.0.0.1 是指容器本身。为了访问使用容器运行dockerd的主机,您必须通过其公共主机名/ IP引用主机,就像是网络上的另一台机器。

Inside a docker container the localhost and 127.0.0.1 refer to the container itself. In order to access the host machine running dockerd with your container you must refer to the host by its public hostname/IP as if it was another machine on the network.

这篇关于curl:(7)无法连接到localhost端口8090:连接被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆