[英]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.