bluehost-banner
How to Create Subdomain in AWS with Route53

How to Create Subdomain in AWS with Route53

In this article, we will see how to create subdomain for your application with using AWS EC2 and Route53.

What is Subdomain?

A subdomain is a website that is a part of another website.

A subdomain can be used to create an additional site, such as a company’s blog or to create an additional email address for the account holder.

Create Subdomain in AWS with Route53

Select Route53 from the services and select your domain hosted Zone from the list

Click on Create record.

Create-Record-in-route53
Create-Record-in-route53

SSH to your instance

Create a Virtual host:

Go to /etc/nginx/sites-available, which will list all available virtual hosts, to create one use below command:

 sudo touch api.example.com
server
{
	listen 80;
	listen [::]:80;
	server_name api.example.com;
	location /
	{
		proxy_pass http://localhost:8083;#whatever port your app run
		proxy_http_version 1.1;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection 'upgrade';
		proxy_set_header Host $host;
		proxy_cache_bypass $http_upgrade;
	}
}

Now To activate created virtual hosts, run the following command:

sudo ln -s /etc/nginx/sites-available/api.example.com /etc/nginx/sites-enabled/

Now restart the nginx using below command:

sudo service nginx reload

Add SSL:

sudo certbot --nginx -d api.example.com

Subscribe to our Newsletter

Stay up to date! Get all the latest posts delivered straight to your inbox.

If You Appreciate What We Do Here On TutsCoder, You Should Consider:

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Leave a Comment