Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
NGINX&;红隼502响应(111:连接被拒绝)_Nginx_Asp.net Core_Kestrel Http Server_Kestrel - Fatal编程技术网

NGINX&;红隼502响应(111:连接被拒绝)

NGINX&;红隼502响应(111:连接被拒绝),nginx,asp.net-core,kestrel-http-server,kestrel,Nginx,Asp.net Core,Kestrel Http Server,Kestrel,我在docker容器中安装了NGINX,它正确地服务于静态内容,因此没有问题。我将它配置为一个代理,指向mac上的红隼。Kestrel在端口5000上的响应很好(通过Curl检查),但由于一些奇怪的原因,NGINX无法连接到它 日志显示: 15连接到时connect()失败(111:连接被拒绝) 上游,客户端:172.17.0.1,服务器:[省略],请求:“获取 /api/values/5000 HTTP/1.1“,上游: “” 我的NGINX配置: location / {

我在docker容器中安装了NGINX,它正确地服务于静态内容,因此没有问题。我将它配置为一个代理,指向mac上的红隼。Kestrel在端口5000上的响应很好(通过Curl检查),但由于一些奇怪的原因,NGINX无法连接到它

日志显示:

15连接到时connect()失败(111:连接被拒绝) 上游,客户端:172.17.0.1,服务器:[省略],请求:“获取 /api/values/5000 HTTP/1.1“,上游: “”

我的NGINX配置:

      location / {
        proxy_pass         http://dotnet;
        proxy_http_version 1.1;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection keep-alive;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;
    }
}
upstream dotnet {
    zone dotnet 64k;
    server 127.0.0.1:5000;
}

由于nginx在您的容器中运行,因此127.0.0.1是容器本地的,而不是运行它的主机

您需要更改IP地址以匹配容器视为主机的内容(请参见此处:)


另外,别忘了打开防火墙上的端口:-)

可能最好在