[英]Which port is my ASP.NET Core 6 app running on in AWS Fargate
I just did the following:我刚刚做了以下事情:
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.