asp.net - 访问 linux 托管的 ASP.NET Core 2.x webapp(无 nginx)

标签 asp.net ubuntu asp.net-core asp.net-core-2.1 kestrel-http-server

我的 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 .
然后在服务器上:
  • 安装 dotnet 运行时
  • 将文件复制到服务器 ( /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/

    相关文章:

    c# - LINQ to Entity Framework 多重连接与多个动态搜索条件

    ASP.NET Core 6 - 从 swagger explorer 中隐藏最小的 api 端点

    c# - LoginStatus 控件无法使用数据库进行基本验证的日志记录

    php - 当用户点击 mailto : html tag 时在 ubuntu 中使用 ssmtp

    python - gmate 错误 - 尝试打开 gmate 时没有名为 gconf 的模块

    docker - Rancher 没有启动。等待 Kubernetes API

    .net - 如何从完整的 .Net 框架测试项目中引用 ASP.NET Core 项目?

    asp.net - COM 异常 - TYPE_E_CANTLOADLIBRARY?

    android - .NET Core Web API 推送到 Apple/Android 推送通知服务器

    c# - 在一个 Nuget 包中定位 .Net Core Framework 和完整的 .Net 4.5/4.6 Framework