Understanding AWS Route 53 and setting up URL for an application on EC2 instance
Amazon Route 53 is a versatile Domain Name System(DNS) service provided by Amazon Web Services. It enables users to register domain names directly through the platform, converting human-friendly URLs into the numerical IP addresses that computers use to communicate. This service ensures seamless access to your web applications by efficiently managing the translation of domain names. Additionally, Route 53 integrates health monitoring to check the performance and availability of your application endpoints, ensuring the traffic is only directed to healthy and operational destinations.
Route 53 offers advanced traffic management capabilities with various routing options, including simple, weighted, latency-based, failover and geolocation routing. These options allow users to direct user traffic in the most efficient and reliable manner. Designed for speed and reliability, Route 53 seamlessly integrates with other AWS services, making it a powerful tool for managing DNS and domain names within cloud-based applications.
"53" in Route 53 is derived from the fact that TCP and UDP port 53 are the standard ports used for DNS services. DNS servers listen for queries on port 53, making it a fitting number for a DNS-related service.
Lets discuss a scenario to understand more. Suppose you have a Tomcat application running on an AWS EC2 instance on port 8080 with HTTPS using AWS Application Load Balancer (ALB) and Route 53.Application should be accessible to the end users with the URL - https://mysimpleapp.test.com. Below are the steps to do this setup:-
Prepare the EC2 instance:
Ensure your Tomcat application is running on port 8080 on your EC2 instance.
Set up the ALB
Create an ALB:
Go to EC2 Dashboard.
Select the Load Balancers under Load Balancing and click Create Load Balancer.
Choose Application Load Balancer.
Configure the basic settings - such as name, scheme(choose internet-facing), Add an HTTPS listener on port 443, select the VPC and AZ where the EC2 instance is located.
Configure Security Groups:
Assign a security group that allows inbound traffic on port 443(HTTPS).
Set up the Target Group:
Create a new target group.
Select instances as the target type.
Set the target group details(name, protocol HTTP, port 8080, and VPC).
Register your EC2 instance with the target group.
Configure Listener rules:
For the HTTPS listener on port 443, add a rule to forward traffic to the target group you created. Rule has 2 sections - condition and action. Set the condition to match the host header. This will be the domain name - mysimpleapp.test.com. You can add extra condition as path if you wish to specify any path(e.g. /#/login,/* etc). Set the Action to Forward to the target group you created earlier which directs traffic to the EC2 instance running Tomcat on port 8080.
Configure SSL/TLS:
During the ALB setup, you will need to configure an SSL certificate for HTTPS. You can use AWS Certificate Manager (ACM) to request or import an SSL certificate and attach it to be the ALB.
Set up Route 53
Register the Domain:
If you don't have the domain test.com, register it via Route 53 or another domain registrar.
Create a Hosted Zone:
In the Route 53 console, navigate to Hosted Zones and create a new hosted zone for test.com.
Create a Record Set:
Inside the hosted Zone for test.com, create a new record set.
Set the name to mysimpleapp(making the full domain mysimpleapp.test.com).
Select A- IPV4 address for the type, since the domain name will ultimately redirect to IP address.
Choose Alias as Yes.
In the Alias Target dropdown, select the ALB you created earlier.
Test the Setup
Allow some time for DNS propagation. Then, navigate to https://mysimpleapp.test.com in a web browse. It should direct traffic through the ALB to your Tomcat application running on EC2 instance on port 8080.
Following the above steps ensures that your Tomcat Application is accessible securely via the URL, utilizing both AWS ALB for HTTPS and Route 53 for DNS management.