AWS Fargate无法通过负载均衡器/公共IP访问

问题描述

在创建AWS Fargate集群之后,我已经在aws ECR上部署了我的spring boot应用程序的docker映像。 PFA的屏幕截图,说明了任务,安全性,服务和群集定义。我可以成功ping通我的公共IP。但是我无法通过负载平衡器或公共ip访问我的应用程序。我尝试访问应用程序的网址是

public_ip:8081 / my_rest_end_point

load_balancer_public_dns:8081 / my_reset_end_point

我测试了使用端口8081和我在Fargate容器配置中为端口映射配置的相同8081端口在本地主机上运行docker映像 (参考:服务定义)。如何访问我的应用程序?我关注了有关Medium和AWS的几乎所有文章

Task Definition

security definition

service definition

cluster definition

Target group

load balancer definition1

load balancer definition2

inbound rules

Updated security rules

service subnet

load balancer subnets

registered target groups

教程如下: https://medium.com/underscoretec/deploy-your-own-custom-docker-image-on-amazon-ecs-b1584e62484

https://medium.com/faun/aws-fargate-services-deployment-with-continuous-delivery-pipeline-b67d33407c88

解决方法

基于评论和聊天讨论。

tutorial followed使用两个子网创建CIDR范围为10.0.0.0/16自定义VPC 。没有没有互联网网关(IGW);随后,在VPC中启动的Fargate任务无法访问互联网,也无法从互联网访问它们。

此问题有两种解决方案

  • 使用默认VPC 可以正确提供Internet访问权限
  • 创建使用 IGW 和相应的路由表设置的自定义VPC(或修改现有的VPC)。 AWS docs中是一个具有Internet访问权限的自定义VPC的示例。