APP in AWS ECS Fargate Can't Connect to Remote Database in Liquid Web.

0

Hi,

I have deployed a Nest.js application on AWS ECS Fargate, and am using a Network Load Balancer with two associated Elastic IPs, one for each subnet. Now, I am attempting to connect to our remote database on Liquid Web. I have already added both IPs to the WHM firewall whitelist settings, and have also added them to the Control Panel under Remote MySQL Hosts. I have checked the security group outbound rules and the network ACLs outbound rules, and everything seems to be in order. Could you please advise on what else I need to check?

Additionally, I have attempted to connect to this remote database via localhost using the same database URL string. After allowing my local public IP in the firewall and Remote MySQL Host, I was able to connect to the database.

Also I can connect to my app using the elastic IP address associated to the network load balancer after deployment.

I hope you can help me. :)

Thank you!

Reyver
gefragt vor 7 Monaten273 Aufrufe
1 Antwort
2
Akzeptierte Antwort

Hello.

Do you mean connecting to the database from a container started on Fargate?
In that case, you need to allow the Fargate container IP address in the database.
NLB is only used to access the container, so the IP address used to access the database will be the Fargate IP address.
Additionally, the IP address of Fargate containers changes when tasks are swapped, etc., so you can use a fixed IP by starting the container in a private subnet and communicating via NAT Gateway.
https://repost.aws/knowledge-center/ecs-fargate-static-elastic-ip-address

To create a static IP address for a Fargate task for outbound traffic, create a NAT gateway. In this scenario, a static IP address is required by the downstream consumer. You must place your Fargate task on a private subnet. You can use the NAT gateway IP address for an IP allow list.

profile picture
EXPERTE
beantwortet vor 7 Monaten
profile picture
EXPERTE
überprüft vor einem Tag
profile pictureAWS
EXPERTE
überprüft vor 6 Monaten
  • Thanks for this. I finally solve the problem. :D

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen