我的 ASP.NET Core 2.1 webapp 在我的开发设置中完美运行。现在我想在生产中测试它。
生产服务器是Ubuntu 18。我关注了the instructions .我还不想设置 nginx,只是做一些快速测试,说明说:
"Either configuration—with or without a reverse proxy server—is a valid and supported hosting configuration for ASP.NET Core 2.0 or later apps".
所以我建立并发布了我的项目:
dotnet publish --configuration Release
.然后在服务器上:
/var/www/myapp
) sudo uwf allow 5000/tcp 80/tcp
dotnet MyApp.dll
(也试过 sudo dotnet MyApp.dll
)它运行时没有错误/警告,并说它正在监听
http://localhost:5000
.在我的本地机器上,我尝试了
http://serveripaddress
(和 http://serveripaddress:5000
)但一无所获(“无法连接”)。我可以使用 ssh、sftp 等访问该服务器 - 只有 http 不起作用。我究竟做错了什么?
最佳答案
发现了问题。我需要使用:
sudo ASPNETCORE_URLS="http://0.0.0.0:5000" dotnet MyApp.dll
然后它记录
Now listening on: http://0.0.0.0:5000
.我可以从远程客户端访问它。
关于asp.net - 访问 linux 托管的 ASP.NET Core 2.x webapp(无 nginx),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52200816/