• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

securitywing

How to Setup AWS CloudFront for Externally Registered Domain Name

by wing

If you do not want to transfer your domain to Amazon DNS(Route 53) and want to use AWS CloudFront to deliver your content, you can use the instructions below to set up your content delivery network.

Scenario 1: you are using an external DNS for CloudFront and do not want to create a hosted zone in  Amazon route 53.

For example, your domain is registered with Namecheap and you have already created a CloudFront distribution for your domain example.com. the easiest solution will be to create a CNAME record in Namecheap DNS and point it to the CloudFront URL.

cname record in namecheap for cloudfront

As you know the CNAME record allows you to only point the subdomain to another domain. You will not be able to send your all traffic from example.com to the CloudFront. Only www.example.com will be forwarded to the CloudFront URL. If you want both the www and non-www or naked/apex domain be forwarded to CloudFront then you need to follow the instruction given below in scenario 2

Scenario 2: you are using an external DNS and  will create a hosted zone in the route 53

The main reason behind creating a hosted zone in Route 53 is that you will be able to create alias record for both the naked domain and teh www domain.

At first create a hosted zone for your domain in route 53 and take note of the NS record. Now log on your to Namecheap account and select the domain name and click on custom DNS. Add all the four NS records in the Namecheap DNS.

namecheap custom dns for aws

Secondly, create a hosted zone for your domain in the AWS Route 53 and then create an A record with an alias. Add the CloudFront URL so that route 53 can point your custom domain name to the CloudFront. Also create an CNAME record so that all your www.example.com traffic gets directed to example.com.

SSL: if you are using CloudFront, make sure you have uploaded a custom SSL in the CloudFront via the IAM role. If you want the CloudFront to send traffic to the EC2 origin via HTTPS , you have to set up the same SSL on the EC2 instance as well. When you have a load balancer between the CloudFront and the EC2, you need to set up the same SSL on the load balancer and set the connection between the LB and the EC2 via the simple HTTP protocol, avoiding the necessity of setting up SSL on the webserver.

 

SSL setup in the CloudFront

You must upload an SSL certificate in the CloudFront via IAM role.

To test CloudFront setup with SSL for your custom domain you need to have a valid SSL. If you want to create a free SSL then you use  ‘LetsEncrypt’ free SSL and upload it to AWS using the following command:

To upload your SSL run the following command from an EC2 instance or from your local machine. Before running the commands below make sure you have set up AWS  access keys on your machine.

aws iam upload-server-certificate –server-certificate-name  youdomain-2019-02-11   –certificate-body file://cert.pem –private-key file://privkey.pem –certificate-chain file://chain.pem –path /cloudfront/production/

 

How to Create LetsEncrypt Certificate using certbot in the EC2 instance?

Make sure your website already has a  ‘A’ record pointing to a web server.
Make sure you set an A record for the domain and it is pointing to your server. It will
help to auto-create the .well-known/acme-challenge file in the root directory and
verify the domain for you.

#Install certbot
yum -y install certbot
#create ssl
certbot certonly  –webroot -w /var/www/html/ -d  yourdomain.com -d  www.yourdomain.com

#Your certificate and chain can be found at: /etc/letsencrypt/live/yourdomain.com/fullchain.pem
Your key file will be saved at:
/etc/letsencrypt/live/yourdomain.com/privkey.pem

Related posts:

  1. How to Mount Amazon EFS in EC2-CentOS Instance
  2. Project Manager Interview Questions and Answers
  3. Cisco Router Security Check for Auditor
  4. How to Share Internet Connection using Android Mobile Tethering

Filed Under: Off Track Tagged With: amazon, AWS, cloudfront

Primary Sidebar

Please help us sharing

Categories

  • AWS
  • Basics
  • Containers
  • Cryptocurrency
  • Cyber
  • Internet Security and Safety
  • IS Audit
  • IT Security Exams
  • Law & Human Rights
  • Network Security Tips
  • Off Track
  • Social Media Governance
  • Tech Comparisons
  • Tech Stack Suitability
  • Telecom
  • Tutorial

CISSP Sample Test

Take a CISSP Sample Test

CISA Sample Test

CISA IT governance Sample test

Please Follow Us

Contact us for Ads

Go to Contact Form

Search

Footer

Copyrights

Protected by Copyscape Duplicate Content Detection Software

Securitywing.com reserves the copyrights of all of its published articles.No contents of this site is permitted to be published to anywhere else in the Internet.If any contents are found in any other websites, securitywing reserves the rights to file a DMCA complaint. But you have the right to use the link of any relevant article of this site to point from your website if you consider that it might improve the quality of your article.

Tags

audit AWS backup basics browser check cisco cloud computer configuration cyber data database email gmail hsrp ids iis informaiton internet kubernetes linux load balancing malware microsoft network protection redundancy risk router security security tips server social media SSL switch test tools vpn vrrp web webserver website windows wordpress

Copyright © 2010-2025 ·All Rights Reserved · SecurityWing.com