Home > Mobile >  How to Map Sub Domains created in Route 53 to application running in EC2 instance with different por
How to Map Sub Domains created in Route 53 to application running in EC2 instance with different por

Time:07-20

I have springboot application with different ports hosted in ec2 instance Domain in Route 53

Domain Name : mydomain.com

App A - 8081, App B - 8085, App c - 8088

Instance IP : 10.xx.xx.xx

domain : test1.mydomain.com point to 10.xx.xx.xx:8081/landingpage &

test2.mydomain.com point to 10.xx.xx.xx:8085/landingpage & test3.mydomain.com point to 10.xx.xx.xx:8088/landingpage

I have some idea in creating Load Balancer and Target Groups in beginner level. Your views are always welcome.

CodePudding user response:

Route53 is DNS web service. It only resolves names to IP addresses, not ports nor URL paths. For that you need to either setup a load balancer for your instance, or using nginx on the instance to manage ports and url path redirections.

CodePudding user response:

As stated by Marcin, Route53 can't resolve port, this is a walk around.. Assuming you already open two ports on your ec2 instance.

  1. Create 2 target groups. One to port 8085, one to port 8088. Register your instance to those 2 target groups
  2. Create application load balancer (ALB). Create 2 CNAME record with subdomain as your need, route both to your ALB DNS
  3. Optional: Create a certificate for your domain (ACM), it should able ssl on *.mydomain.com, register the certificate to your HTTPS load balancer.
  4. Create listening rule on port 443 of your ALB (80 if you don't use ACM) , route depending on your host name, each hostname will route to one target group.
  • Related