简体   繁体   English

访问在 Linux VPS 上运行的 ASP.Net Core MVC 应用程序

[英]Accessing ASP.Net Core MVC app running on Linux VPS

What do I need to look out for to get an ASP .NET Core MVC app running on a Linux VPS accessible to the outside world?我需要注意什么才能让ASP .NET Core MVC应用程序在外部世界可以访问的Linux VPS上运行?

On the Linux VPS and is running my app like this: dotnet bin/Release/net5.0/app-name.dll在 Linux VPS 上运行我的应用程序是这样的: dotnet bin/Release/net5.0/app-name.dll

All seems well - but I can't access the application at: http://the-ip-address:port_number neither on https://... here.一切似乎都很好 - 但我无法在https://...这里访问应用程序: http://the-ip-address:port_number

All is running fine in the logs.一切都在日志中运行良好。 But the application is not accessible just yet.但该应用程序尚不可访问。

I am clearly missing something... but I am not sure what.我显然错过了一些东西......但我不确定是什么。

I am not using a reverse proxy just yet.我还没有使用反向代理。 Although I did try that and there seems to be an issue with the ASP .Net app at this stage.尽管我确实尝试过,但现阶段 ASP .Net 应用程序似乎存在问题。

Any pointers will be appreciated.任何指针将不胜感激。

You should set Kestrel Listening IP and Port in program.cs configuration as follow :您应该在 program.cs 配置中设置 Kestrel 侦听 IP 和端口,如下所示:

public static IHostBuilder CreateHostBuilder(string[] args) =>
         Host.CreateDefaultBuilder(args)
             .ConfigureWebHostDefaults(webBuilder =>
             {
                 webBuilder
                 .UseKestrel()
                 .UseUrls("http://0.0.0.0:80", "https://0.0.0.0:443")                   
                 .UseStartup<Startup>();

             });

.UseKestrel() determine you are using kestrel rather than IIS for hosting and running your application .UseKestrel() 确定您使用的是 kestrel 而不是 IIS 来托管和运行您的应用程序

.UseUrls("http://0.0.0.0:80", "https://0.0.0.0:443") means your VPS serve your application to client via main IP address with Http and Https ports .UseUrls("http://0.0.0.0:80", "https://0.0.0.0:443") 表示您的 VPS 通过带有 Http 和 Https 端口的主 IP 地址为您的应用程序提供服务

You have to open Http and Https Ports in your Linux firewall check your physical or cloud firewall if any exist您必须在 Linux 防火墙中打开 Http 和 Https 端口 检查您的物理或云防火墙是否存在

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 运行时出现 InvalidOperationException ASP.NET Core MVC Web App - InvalidOperationException while running ASP.NET Core MVC Web App Azure中的ASP.NET MVC Core应用 - ASP.NET MVC Core app in Azure 在 Linux 上的 ASP.NET Core MVC 项目中构建身份脚手架后运行项目时出现问题 - Problem running project after Identity scaffolding in ASP.NET Core MVC project on Linux 无法从服务器外部访问linux上的asp.net核心mvc应用程序 - asp.net core mvc app on linux can't be reached from outside the server Linux 上的 ASP.NET Core MVC 应用程序 - Raspberry Pi 显示不正确 - ASP.NET Core MVC App on Linux - Raspberry Pi Not displaying correctly 使用 ASP.NET Core 1.1 (MVC) 访问类库中的 httpcontext - Accessing httpcontext in class library with ASP.NET Core 1.1 (MVC) Linux MONO是否支持ASP.NET Core 2.2 MVC? - Does Linux MONO support ASP.NET Core 2.2 MVC? 在 Linux 主机上部署 Asp.net 核心 mvc 网站(godaddy) - Deploy Asp.net core mvc website on Linux hosting (godaddy) ASP.NET Core应用到Azure应用服务上的Linux - ASP.NET Core app to Linux on Azure App Service 从 ASP.NET 核心应用程序访问 Azure KeyVault 中的证书 - Accessing certificate in Azure KeyVault from ASP.NET Core app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM