How to Add a Domain with AWS Backend: A Step-by-Step Guide

Step 1: Set Up Your Domain on GoDaddy
Create a GoDaddy Account: If you don’t already have one, sign up for a GoDaddy account.
Purchase a Domain: Buy the domain you want to use for your application.
Edit Nameservers:
Go to your GoDaddy dashboard and navigate to the "My Domains" section.
Select the domain you want to configure and click on "Manage DNS."
Update the nameservers to point to AWS Route 53.
Step 2: Configure AWS Route 53
Create a Hosted Zone:
Log in to your AWS Management Console.
Navigate to Route 53 and click on "Create Hosted Zone."
Enter your domain name and set the type to Public Hosted Zone.
Click "Create."
Update Nameservers in GoDaddy:
After creating the hosted zone, AWS will provide you with four nameservers.
Go back to your GoDaddy DNS settings and replace the existing nameservers with the ones provided by AWS.
Step 3: Deploy Your Application on AWS EC2
Launch an EC2 Instance:
In the AWS Management Console, navigate to EC2 and launch a new instance.
Choose an appropriate Amazon Machine Image (AMI) and configure the instance settings.
Deploy your Node.js application on the EC2 instance.
Note the Public IP:
- Once the instance is running, note down the public IP address assigned to it.
Step 4: Configure Nginx on Your EC2 Instance
Connect to Your EC2 Instance via SSH:
Use an SSH client to connect to your EC2 instance.
Example:
ssh -i your-key.pem ec2-user@your-ec2-public-ip
Navigate to the Nginx Configuration Directory:
Run the following command to access the Nginx configuration files:
cd /etc/nginx/sites-available
Edit the Default Nginx Configuration File:
Open the
default
file using a text editor likenano
:sudo nano default
If you encounter a permission error, grant the necessary permissions:
sudo chmod 777 -R /etc/nginx/sites-available
Update the
server_name
field with your domain name and add the public IP of your EC2 instance.Example:
server { listen 80; server_name yourdomain.com www.yourdomain.com; location / { proxy_pass http://your-ec2-public-ip:3000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }
Save and close the file.
Restart Nginx:
Restart the Nginx server to apply the changes:
sudo systemctl restart nginx
Step 5: Enable HTTPS with AWS Certificate Manager (ACM)
Request a Certificate:
Navigate to AWS Certificate Manager (ACM) in the AWS Management Console.
Click on "Request a Certificate" and select "Public Certificate."
Enter your domain name (e.g.,
yourdomain.com
andwww.yourdomain.com
).Complete the domain validation process by adding the required DNS records in Route 53.
Update Nginx Configuration for HTTPS:
Modify your Nginx configuration file to include the SSL certificate:
server { listen 443 ssl; server_name yourdomain.com www.yourdomain.com; ssl_certificate /etc/nginx/ssl/yourdomain.crt; ssl_certificate_key /etc/nginx/ssl/yourdomain.key; location / { proxy_pass http://your-ec2-public-ip:3000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }
Save and close the file, then restart Nginx:
sudo systemctl restart nginx
Step 6: Verify Your Setup
Test Your Domain:
Open a web browser and navigate to your domain (e.g.,
http://yourdomain.com
).Ensure that your application loads correctly.
Check HTTPS:
- Navigate to
https://yourdomain.com
to verify that your site is securely served over HTTPS.
- Navigate to
Conclusion
By following these steps, you’ve successfully added a domain with an AWS backend, configured Nginx to serve your application, and enabled HTTPS using AWS Certificate Manager. This setup ensures your application is secure, professional, and accessible via a custom domain.
Subscribe to my newsletter
Read articles from ihtizaz Ahmad directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

ihtizaz Ahmad
ihtizaz Ahmad
I'm ihtizaz Ahmad, a Full Stack Developer with 4+ years of experience. I specialize in creating web applications with Angular, React.js,Next J's, Node.js, Nest.js, and various databases.