Skip to content

Can not access server running in a docker container on an EC2 with a load balancer via a subdomain pointing at a loadbalancer.

0

I currently have a subdomain pointing at a load balancer. I have created a SSL/TLS certificate that includes the domains, api.domain.dev and domain.dev. I have added the CNAMES values accordingly to the domain DNS records.

I have also added a CNAME with HOST:api.domain.dev and ANSWER: the DNS url of the load balancer.

The load balancers have an HTTP and HTTPS listener on ports 80 and 443 respectively. The load balancer is associated with 2 subnets with Auto-assign public IPv4 address set to true.

Not sure what configuration is causing the issue.

The server is up and running. I can ssh into the EC2 and send requests to localhost:5000/api.

asked 2 years ago581 views

1 Answer
0

Hi

Target Port Ensure the target group in your load balancer is configured to forward traffic to the correct port on your EC2 instance where the Docker container is listening. Double-check that the target port in the load balancer matches port 5000 where your server listens (based on your localhost:5000/api access).

Security Group Verify that the security group of your EC2 instance allows traffic on port 5000 (or the container port) from the load balancer's security group.

Health Checks Verify the load balancer health checks are functioning correctly.

References: https://stackoverflow.com/questions/66864290/aws-ec2-how-to-setup-load-balancer-to-match-docker-container-on-ec2-instance

https://aws.amazon.com/blogs/compute/how-to-quickly-setup-an-experimental-environment-to-run-containers-on-x86-and-aws-graviton2-based-amazon-ec2-instances-effort-to-port-a-container-based-application-from-x86-to-graviton2/

EXPERT

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.