![](/img/trans.png)
[英]How does AWS Fargate handle the health status of ASP.NET Core app hosted in it?
[英]Which port is my ASP.NET Core 6 app running on in AWS Fargate
我刚刚做了以下事情:
现在我可以看到我的任务正在运行,但我不知道如何连接到 API。端口 80 和 443 什么都不做,7260 和 5260 也不做,它们在本地用于调试。
下面是我当前的所有配置(我很绝望,添加了我希望可能相关的各种端口)。
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:
{
"$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
}
}
}
任务定义上的端口映射:
任务 ENI 安全组设置(允许来自任何地方的一切 [是的,仅用于测试]):
如果有人有任何建议,我将不胜感激。
编辑
我设法通过将以下内容添加到我的 Dockerfile 来设置应用程序启动的端口
EXPOSE 80
EXPOSE 443
ENV ASPNETCORE_URLS="http://*:80;https://*:443"
谢谢大家,您的评论为我指明了正确的方向。
我建议您将以下环境变量传递到您的 Fargate 服务中,这样您就可以管理应用程序所在的端口:
ASPNETCORE_URLS: http://0.0.0.0:8080
在此示例中,您的应用程序将在端口 8080上公开
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/taskdef-envfiles.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.