Last updated Jan 11, 2023

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.

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

Tags

Available for projectsLet’s build together

Need this built properly,
not just explained?

I take on Angular and NestJS work directly — auth systems, multi-tenant SaaS, API rewrites and the deploy pipeline underneath them. You talk to the person writing the code.

Projects delivered
20+ Projects delivered
Angular • NestJS
7+ years Angular • NestJS
Average reply time
1 day Average reply time

What I can help with

  • Auth and permissions systems
  • Multi-tenant SaaS foundations
  • API design and rewrites
  • Deploy pipelines and VPS setup
  • Bug fixing and performance optimization
Send me a message

Tell me about your project and I’ll get back with a realistic scope and price.

Turn
Your Ideas
Into Reality

Stay in the loop

Get the finished tutorials, projects and resources in your inbox.

Join 5,000+ developers and get new tutorials, source code, product updates and exclusive content — straight to your inbox.

  • No spam
  • Useful content only
  • Unsubscribe anytime

Subscribe to TutsCoder

Be the first to get new tutorials, projects and tips.

Join 5,000+ developers already learning with us.

Learn
Build
Grow

Discussion

0 comments

Share your thoughts, ask questions or suggest improvements. Let’s learn and grow together!

No comments yet — be the first to start the discussion.

Join the discussion

Sign in to join the discussion. Your account also keeps your saved tutorials and path progress.