How to use domain provider’s email hosting with Route53 (Subdomain Delegation)

You may also watch the video version of this blog post here.

When we deploy a production application we usually to attach a custom domain so our customers can easily find it on the internet. If you have a web application (E.g. S3 static web app, beanstalk web app, etc…) on AWS. Normally we create a hosted zone on Route53 and copy the nameservers and replace them with your domain provider’s nameservers. This is the standard process.

Problem

But sometimes, we may already have other applications that are not running on AWS (e.g. Email servers) attached to the domain provider. When we paste Route53 nameservers for the parent domain, those applications stop working.

Solution

Now you probably want your application on AWS to attach to a subdomain. (e.g. If your parent domain is example.com, you may want your web application attached to app.example.com). So how do this? There are several ways really. You can set up URL forwarding with or without URL masking, or you can create a CNAME record to AWS application endpoint. But what I usually do is delegating sub-domain DNS resolution to AWS. So I can use AWS specific DNS records like “Alias” records to serve my applications.

Example

Let’s imagine we have a beanstalk environment that runs a web application. We need to attach a subdomain. But the original domain has a mail server configured so we cannot replace the parent domain nameservers with AWS nameservers. Instead, let’s follow these steps to setup subdomain for the website with subdomain delegation.

In this example, I use namecheap.com as my domain name registrar.

Step 01

Goto route53 and create a hosted zone. The hosted zone name should be the domain name. (E.g. awslearners.online)

Create a hosted zone for the parent domain name

Step 02

Goto your domain provider. E.g. Namecheap, GoDaddy etc… and navigate to the DNS advance settings page. Create new Nameserver records for the sub-domain you plan to delegate to Route53.

If you’ve registered the domain using namecheap.com, login to the account and goto the Advance DNS Settings of the domain you have purchased. (Similar configuration is available for other domain registers like GoDaddy.com etc…)

Now click on Add New Record then select NS record from the list and start adding nameserver records found for your hosted zone in Route53 one by one.

In the example below, the Host is added as “app” so the sub-domain is app.awslearner.online

Add new nameserver records

Now, all requests for app.awslearner.com will be resolved by the nameservers of Route53. All other requests for the root domain and other subdomains will be resolved by namecheap.com nameservers. Thereby MX records for mail-servers will still work since the root-domain nameservers are still handled by namecheap.com.

Step 03

Finally, go back to AWS Route53 hosted zone and create the corresponding subdomain record and point it to the beanstalk application using AWS specific “Alias” record.

AWS specific Alias records have many benefits over general CNAME records. (See the documentation)

Once the record is created, you may have to wait sometime (up to 48hours) for DNS propagation to happen. After that, you should be able to browse your beanstalk web application with the subdomain.

Hope this helps!

Please follow and like us:

Published by

Manoj

Manoj

Hi everyone! I'm Manoj and I love cloud computing. This blog is connected to my Youtube channel where I share my experience in working with popular cloud platforms and new/hot/trending cloud services. Hey if you want to become a cloud computing expert, make sure you've subscribed to my Youtube channel and never miss weekly uploads!

Leave a Reply

Your email address will not be published. Required fields are marked *