DEV Community

S3CloudHub
S3CloudHub

Posted on

Setup AWS EC2 and Configure Route 53: Domain Redirection Made Easy!

Introduction

In the digital landscape, having a reliable web hosting solution and an efficient domain management system is crucial for businesses and developers alike. Amazon Web Services (AWS) provides robust services like EC2 (Elastic Compute Cloud) for hosting applications and Route 53 for domain management. This guide will provide a step-by-step walkthrough on setting up an AWS EC2 instance and configuring Route 53 for domain redirection, empowering you to enhance your online presence with ease.

Image description

Why Choose AWS EC2 and Route 53?

  • Scalability: AWS EC2 allows you to scale your resources based on demand, ensuring optimal performance.
  • Reliability: With AWS’s global infrastructure, you can expect high availability and redundancy.
  • Cost-Effectiveness: Pay only for what you use, making it a budget-friendly option for startups and enterprises alike.
  • Domain Management: Route 53 simplifies domain registration, DNS routing, and health checking, making it an all-in-one solution.

For a visual walkthrough of the concepts covered in this article, check out my YouTube Video:-
image alt text here

Step 1: Launching Your EC2 Instance

1.1 Log In to the AWS Management Console

Begin by logging into your AWS Management Console with your credentials.

1.2 Navigate to EC2

From the Services menu, select EC2 to access the EC2 dashboard.

1.3 Start the Instance Launch Wizard

Click on the Launch Instance button to begin setting up your server.

1.4 Choose an Amazon Machine Image (AMI)

Select a suitable AMI based on your project requirements. Popular options include:

  • Amazon Linux 2
  • Ubuntu Server

1.5 Select Instance Type

Choose an instance type according to your needs. The t2.micro instance is often recommended for those eligible for the free tier.

1.6 Configure Instance Details

  • Network: Choose the default VPC.
  • IAM Role: Assign a role if your application requires access to AWS services.
  • Monitoring: Enable detailed monitoring if necessary.

1.7 Add Storage

Modify the storage settings if needed. The default settings should suffice for initial setups.

1.8 Configure Security Group

  • Create a New Security Group: Name it descriptively.
  • Inbound Rules: Allow:
    • HTTP (port 80)
    • HTTPS (port 443)
    • SSH (port 22) for secure access.

1.9 Review and Launch

Check all settings, select your key pair, and click Launch. Your EC2 instance will be ready shortly.

Step 2: Connect to Your EC2 Instance

Once your instance is running, connect to it via SSH. Here’s how:

  1. Open a terminal or command prompt.
  2. Enter the following command (replace <key-pair-name> and <ec2-public-ip>):
ssh -i <key-pair-name>.pem ec2-user@<ec2-public-ip>
Enter fullscreen mode Exit fullscreen mode

Step 3: Install and Configure a Web Server

To serve web content, you’ll need to install a web server on your EC2 instance. We’ll use Apache for this guide.

3.1 Update Your Package Index

sudo yum update -y       # For Amazon Linux
Enter fullscreen mode Exit fullscreen mode

3.2 Install Apache

sudo yum install httpd -y
Enter fullscreen mode Exit fullscreen mode

3.3 Start the Apache Service

sudo systemctl start httpd
sudo systemctl enable httpd
Enter fullscreen mode Exit fullscreen mode

3.4 Verify the Installation
Open your browser and enter your EC2 public IP. You should see the Apache test page, indicating that your web server is operational.

Step 4: Configure AWS Route 53 for Domain Redirection

Now, let’s set up Route 53 to manage your domain effectively.

4.1 Access Route 53
From the AWS Management Console, search for and select Route 53.

4.2 Create a Hosted Zone

  • Click on Hosted Zones and then Create Hosted Zone.
  • Enter your domain name and select Public Hosted Zone to make it accessible to the internet.

4.3 Add Record Set

  1. Click on your newly created hosted zone.
  2. Select Create Record Set and configure the following:
  • Name: Leave blank for the root domain or enter www for a subdomain.
  • Type: Choose A — IPv4 address.
  • Alias: Set to No.
  • Value: Input the public IP address of your EC2 instance.
  • Click Create to save the record.

4.4 Update Your Domain Registrar
If your domain is registered with a different provider, update the NS (Name Server) records at your registrar to point to the Route 53 name servers. This step is essential for the domain to correctly route to your EC2 instance.

Step 5: Test Your Domain Redirection

After DNS propagation (which can take a few minutes), enter your domain in a browser. You should see the Apache welcome page, confirming that your domain is successfully pointing to your EC2 instance.

Troubleshooting Common Issues
DNS Propagation Delay: Sometimes, DNS changes can take time to propagate. Be patient and try again later.
Security Group Rules: Ensure your security group allows HTTP and HTTPS traffic.
Apache Not Running: If you don’t see the web page, check that the Apache service is active with:
sudo systemctl status httpd

Conclusion
Setting up AWS EC2 and configuring Route 53 for domain redirection is a powerful way to establish your online presence. With AWS’s scalability and reliability, you can focus on your application while leveraging robust infrastructure. Whether you’re a developer, business owner, or tech enthusiast, mastering these tools can greatly enhance your web management capabilities.

Call to Action Are you ready to elevate your website’s performance and reliability? Start your journey with AWS today! If you have questions or need assistance, feel free to leave a comment below.

Connect with Us!
Stay connected with us for the latest updates, tutorials, and exclusive content:

WhatsApp:-https://www.whatsapp.com/channel/0029VaeX6b73GJOuCyYRik0i
Facebook:-https://www.facebook.com/S3CloudHub
Youtube:-https://www.youtube.com/@s3cloudhub
Free Udemy Course:-https://github.com/S3CloudHubRepo/Udemy-Free-Courses-coupon/blob/main/README.md

Connect with us today and enhance your learning journey!

Top comments (0)