我在Visual Studio 2019的dotnetcore 2.1中开发了一个Web api。它返回默认的{value1,value2}。我想将此API部署在AWS Windows Server 2019 EC2实例中,并通过公共IP公开它
我已经完成了以下配置
launchSettings.json:
"Ebooking.Platform.Provider": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "api/provider",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:5000"
},
在Program.cs
var configuration = new ConfigurationBuilder()
.AddCommandLine(args)
.Build();
var hostUrl = configuration["hosturl"];
if (string.IsNullOrEmpty(hostUrl))
hostUrl = "http://0.0.0.0:6000";
var host = new WebHostBuilder()
.UseKestrel()
.UseUrls(hostUrl) // <!-- this
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.UseConfiguration(configuration)
.Build();
host.Run();
在EC2实例中,我通过以下方式在防火墙设置中打开端口
netsh advfirewall firewall add rule name="Http Port 5000" dir=in action=allow protocol=TCP localport=5000
netsh advfirewall firewall add rule name="Http Port 6000" dir=in action=allow protocol=TCP localport=6000
我尝试全部使localhost和0.0.0.0具有相同的端口,但仍然存在以下问题:
请告知