gpt4 book ai didi

c# - ASP.NET Core 2.0 ngrok 502 网关错误

转载 作者:太空狗 更新时间:2023-10-29 18:19:44 27 4
gpt4 key购买 nike

我一直在 ASP.NET 4.X 中使用 ngrok,没有遇到任何问题。

不幸的是,当我尝试在 ASP.NET Core 2 中转发应用程序构建时,我遇到了一个我无法解决的问题。

我尝试了以下命令组合来启动 ngrok:

ngrok http 44374-host-header="localhost:44374"

ngrok http -host-header=rewrite localhost:44374

ngrok http 44374

所有结果都一样。 Ngrok 隧道启动,但是当我尝试打开给定的转发 url 时,站点正在加载几分钟,然后显示 502 Bad Gateway 错误。它适用于 http 和 https 版本。

以管理员身份运行 Visual Studio 或 ngrok 没有帮助。

Website works correctly with localhost

Running website with ngrok gives 502 Bad Gateway error

最佳答案

我解决了我的问题。

properties/launchSettings.json 内容:

{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:59889/",
"sslPort": 44374
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "https://localhost:44374/",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"NgrokTEST": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:59890/"
}
}
}

因此,事实证明 ASP.NET Core 使用不同的端口进行 SLL 连接,并且默认使用它。

在 ngrok 中将端口更改为正常端口(在我的例子中是 59890)解决了问题。

关于c# - ASP.NET Core 2.0 ngrok 502 网关错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49134294/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com