加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

curl:(7)无法连接到localhost端口8090:连接被拒绝

发布时间:2020-12-13 19:24:50 所属栏目:Linux 来源:网络整理
导读:需要帮忙.一直试图找到解决这个问题的方法,看不到答案,或者说我没有遇到任何问题. 我有一个带NGINX的docker容器,充当反向代理. Docker for Windows 1.12.5版(9503). upstream mysite { server 127.0.0.1:8090; #server localhost:8090; (have also tried thi
需要帮忙.一直试图找到解决这个问题的方法,看不到答案,或者说我没有遇到任何问题.

我有一个带NGINX的docker容器,充当反向代理. Docker for Windows 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是在我的主机上的IIS上托管的网站的URL.当我访问NGINX上的URL时,我收到以下错误

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" "-"

试图访问主机上的URL

(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?如果是,那么我错了.

如果我使用google.co.in而不是127.0.0.1:8090,则相同的配置有效.

谢谢.

解决方法

在docker容器内,localhost和127.0.0.1引用容器本身.要使用您的容器访问运行dockerd的主机,您必须通过其公共主机名/ IP引用主机,就好像它是网络上的另一台机器一样.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读