Skip to content

Mapping a public domain to our aws cluster

0

We are using an aws cluster that runs our two docker containers that uses within the cluster a aws far gate.

our server is right now reachable with http://18.196.174.144:5173/, and I want to connect it with a public domain, but i cant enter the port in the domains dns record because the port number cannot be included in a DNS resolution

2 Answers
0

To map your public domain to your AWS cluster without including the port number in the DNS record, you'll need to use Amazon Route 53 in combination with a load balancer. Here's how you can approach this:

  1. Set up an Application Load Balancer (ALB) in front of your ECS cluster. The ALB can handle the routing of traffic to your containers running on Fargate.

  2. Configure the ALB to listen on port 80 (HTTP) and/or 443 (HTTPS) and forward traffic to your containers on port 5173.

  3. Create a public hosted zone in Amazon Route 53 for your domain.

  4. Create an A record in your Route 53 hosted zone that points to the ALB. You can use an Alias record which directly maps to the ALB's DNS name.

  5. If you want to use HTTPS (recommended for security), you'll need to set up an SSL/TLS certificate. You can use AWS Certificate Manager to provision a certificate for your domain.

By following these steps, users will be able to access your application using your domain name without specifying a port number. The ALB will handle the port mapping internally, forwarding requests to the correct port on your Fargate tasks.

Remember to update your security groups to allow traffic on the new ports (80/443) to the ALB, and from the ALB to your Fargate tasks on port 5173.

This setup not only solves your immediate problem but also provides additional benefits like SSL termination, improved load distribution, and easier management of multiple services behind a single domain.

Sources
DNS - Building a Scalable and Secure Multi-VPC AWS Network Infrastructure
Troubleshoot connection to AWS service endpoints from Linux | AWS re:Post

answered 2 years ago

  • This did not work, can anyone help me if this solution is correct and where our mistake could be?

0

To add to the above answer - here are the documents on how to set up forwarding rules on your ALB: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-listeners.html#listener-rules

These will enable you to have your ALB respond to HTTP/S requests on 80 & 443 and then forward those requests to a target group of servers on the custom port 5173.

here is another re:post that breaks this down in more detail: https://repost.aws/questions/QU2XlcAdvyR3--QKTL700tqw/specify-port-mapping-for-container-in-ecs

AWS

answered 2 years ago

  • I have a question about the re:post, in step number 6

    ECS service: When creating or updating your ECS service, configure it to use the Fargate launch type and associate it with the ALB and target group created earlier. In the networkConfiguration section, specify the subnets and security group you created for your service.

    i can see for my ecs service that i dont have any load balancer or target group associated with it, but i cant find where to add them Where exactly can I do these steps? I cant seem to find any of that

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.