[英]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.