简体   繁体   English

哪个端口是我在 AWS Fargate 中运行的 ASP.NET Core 6 应用程序

[英]Which port is my ASP.NET Core 6 app running on in AWS Fargate

I just did the following:我刚刚做了以下事情:

  1. Created an ASP.NET Core 6 API in Visual Studio with the docker option selected在 Visual Studio 中创建了一个 ASP.NET Core 6 API 并选择了 docker 选项
  2. Built the docker image构建了 docker 镜像
  3. Uploaded the image to AWS ECR将图像上传到 AWS ECR
  4. Crated a cluster, task definition and service创建集群、任务定义和服务

Now I can see my task running, but I don't know how to connect to the API. Port 80 and 443 don't do anything and neither do 7260 and 5260, which are used locally for debugging.现在我可以看到我的任务正在运行,但我不知道如何连接到 API。端口 80 和 443 什么都不做,7260 和 5260 也不做,它们在本地用于调试。

Below is my current config for everything (I got desperate and added all sorts of ports I was hoping might be relevant).下面是我当前的所有配置(我很绝望,添加了我希望可能相关的各种端口)。

Dockerfile: Dockerfile:

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
EXPOSE 7260
EXPOSE 49159
EXPOSE 5260
...

launchSettings.json in the project:项目中的launchSettings.json:

{
  "$schema": "https://json.schemastore.org/launchsettings.json",
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:57003",
      "sslPort": 44385
    }
  },
  "profiles": {
    "CoffeSubscription": {
      "commandName": "Project",
      "launchBrowser": true,
      "launchUrl": "swagger",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "applicationUrl": "https://localhost:7260;http://localhost:5260",
      "dotnetRunMessages": true
    },
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "launchUrl": "swagger",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "Docker": {
      "commandName": "Docker",
      "launchBrowser": true,
      "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
      "publishAllPorts": true,
      "useSSL": true
    }
  }
}

Port mappings on task definition:任务定义上的端口映射:

在此处输入图像描述

Task ENI security group settings (Allow everything from everywhere [Yes, for testing only]):任务 ENI 安全组设置(允许来自任何地方的一切 [是的,仅用于测试]):

在此处输入图像描述

If anybody has any advice I'd be immensely grateful.如果有人有任何建议,我将不胜感激。

EDIT编辑

I managed to set the port the app starts on by adding the following to my Dockerfile我设法通过将以下内容添加到我的 Dockerfile 来设置应用程序启动的端口

EXPOSE 80
EXPOSE 443

ENV ASPNETCORE_URLS="http://*:80;https://*:443"

Thanks everybody your comments pointed me in the right direction.谢谢大家,您的评论为我指明了正确的方向。

I will suggest you to pass the following environment variable into your Fargate service, so you can manage the port your application lives on:我建议您将以下环境变量传递到您的 Fargate 服务中,这样您就可以管理应用程序所在的端口:

ASPNETCORE_URLS: http://0.0.0.0:8080

In this example will your application be exposed on port 8080在此示例中,您的应用程序将在端口 8080上公开

https://docs.aws.amazon.com/AmazonECS/latest/developerguide/taskdef-envfiles.html https://docs.aws.amazon.com/AmazonECS/latest/developerguide/taskdef-envfiles.html

暂无
暂无

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

相关问题 AWS Fargate 如何处理其中托管的 ASP.NET Core 应用程序的健康状况? - How does AWS Fargate handle the health status of ASP.NET Core app hosted in it? ASP.NET 核心应用程序未在 AWS 中运行 Linux EC2 实例而不是显示 Apache 测试页 - ASP.NET Core Application not Running in AWS Linux EC2 instance instead showing Apache Test Page AWS Fargate - 从本地无法连接到在 aws fargate 上运行的 java 应用程序的 jmx 端口 - AWS Fargate - From local Unable to connect to jmx port of java application running on aws fargate 如何在 AWS 上托管 ASP.NET 核心 Blazor WebAssembly 托管应用程序? - How to host an ASP.NET Core Blazor WebAssembly Hosted App on AWS? ASP.NET AWS 中托管的 Core 6 应用程序 Lambda function URL 处理程序 - ASP.NET Core 6 app hosted in AWS Lambda function URL Handler Azure Web 应用程序与 Linux 并将 GLIBC 2.29 与我的 ASP.NET Core 7 应用程序捆绑在一起 - Azure Web App with Linux and bundling GLIBC 2.29 with my ASP.NET Core 7 App .NET 5 ASP.NET 核心应用程序未在 Azure 中启动 - .NET 5 ASP.NET Core App not starting in Azure ASP.net 核心 docker https on Azure 应用服务容器 - ASP.net core docker https on Azure App Service Containers 从ASP.NET Core访问Azure App Service ConnectionString - Access Azure App Service ConnectionString from ASP.NET Core ASP.NET Core - 从不同端口同时服务 API 和 SPA React - ASP.NET Core - Serve both API and SPA React from different port
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM