简体   繁体   English

无法在EC2上运行的Cant访问点网核心应用程序

[英]Cant access dot net core application running on ec2

Im having issues reaching my .netcore app running on a windows 2016 server instance. 我在Windows 2016服务器实例上运行我的.netcore应用程序时遇到问题。

project.json: project.json:

    {
  "dependencies": {
    "Microsoft.AspNetCore.Mvc": "1.0.1",
    "Microsoft.AspNetCore.Routing": "1.0.1",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging": "1.1.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
    "Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "HtmlAgilityPack.NetCore": "1.5.0.1",
    "Microsoft.Extensions.Configuration.CommandLine": "1.0.0"
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
  },

  "frameworks": {
    "netcoreapp1.1": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "version": "1.1.0",
          "type": "platform"
        }
      }
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true,
    "outputName": "chromagram"
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "**/*.cshtml",
      "appsettings.json",
      "web.config"
    ]
  },
  "runtimes": {
    "win10-x64": {}
  },
  "scripts": {
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

Program.cs main function: Program.cs主要功能:

public class Program
{
    public static void Main(string[] args)
    {

        var host = new WebHostBuilder()
            .UseKestrel()
            .UseUrls("http://0.0.0.0:6000")
            .UseContentRoot(Directory.GetCurrentDirectory())
            .UseIISIntegration()
            .UseStartup<Startup>()
            .Build();

        host.Run();
    }
}

当我运行该应用程序时,它运行良好。

当我尝试在运行该服务器的服务器上访问localhost:6000时,它运行良好。

But when I try to connect to the server from any other machine on port 6000 I get no response. 但是,当我尝试从端口6000上的任何其他计算机连接到服务器时,没有任何响应。 (I have added inbound requests on port 6000 to the ec2 security group) (我已将端口6000上的入站请求添加到ec2安全组)

.UseUrls("http://0.0.0.0:6000")

This should mean that its listening on all network interfaces, but it doesnt seem to be. 这应该意味着它在所有网络接口上进行侦听,但事实并非如此。

I had the same issue with EC2 and Mike B's comment above was the fix. 我在EC2上也遇到了同样的问题,上面的Mike B的评论已解决。 In the AWS Security Group, add TCP port 6000 for your IP (or 0.0.0.0/0 if you don't care about security). 在AWS安全组中,为您的IP添加TCP端口6000(如果您不关心安全性,则添加0.0.0.0/0)。 Then, on your Windows Server EC2 instance, go to Control Panel > Windows Defender Fire Wall > Advanced. 然后,在Windows Server EC2实例上,转到“控制面板”>“ Windows Defender Fire Wall”>“高级”。 Manually add inbound rule for Port > TCP > 6000. On another server, try accessing your dotnet core app with either http://:6000 and it should work. 手动为“端口”>“ TCP”>“ 6000”添加入站规则。在另一台服务器上,尝试使用http://:6000访问dotnet核心应用程序,它应该可以工作。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM