ESC Fargate 在 HTTP 上运行良好,但在 HTTPS 上它每 3 分钟重新创建一次任务

ESC Fargate working fine with HTTP but on HTTPS it recreate tasks each 3 minutes

我有一个包含两个容器的任务定义:

和应用程序负载均衡器 (ALB)

我的应用程序在此配置 (HTTP) 下运行良好,但当我集成 HTTPS 时,Fargate shutdown/recreate 每 3 分钟执行一次任务。

我为集成 https 添加的更改:

注意:新部署 (HTTPS) 从浏览器运行,另一方面 shutdown/recreate 我遇到问题的任务。

我有这个错误:

Task failed ELB health checks in (target-group arn:aws:elasticloadbalancing:eu-west-3:XXXXX:targetgroup/GLOBAL_TARGET/XXXXXXXXXX)

我正在为 https 使用这个 nginx 配置:

server {
    listen 80;

    index index.html;
    root /usr/share/nginx/html;

    error_log  /var/log/nginx/error.log;
    client_max_body_size 500M ;

    if ( $http_x_forwarded_proto != 'https' ) {
      return 301 https://$host$request_uri;
    }

    location /api/ {
        proxy_pass http://localhost:8080/api/;
    }
    location / {
        try_files $uri $uri/ /index.html;
    }
}

您的 Fargate 服务的运行状况检查失败。

试试这个,

创建 ALB 时,监听负载均衡器到端口 443 和目标组。监听 80 端口。

在端口 80 使用 Target Group 应该像 Ahishek 所说的那样工作。端口:80 |协议:HTTP

我刚刚从我的 nginx 文件和负载均衡器上的其他配置中删除了这段代码

if ( $http_x_forwarded_proto != 'https' ) {
   return 301 https://$host$request_uri;
}

谢谢