Amazon CloudFront is a web service that helps in faster distribution of static and dynamic web content to users. CloudFront helps in delivering content through a global network of data centers known as edge locations. Generally, users want to set up a custom domain for CloudFront rather than using the default CloudFront domain name by Amazon.
The following discussion would provide reliable guidance on the steps for setting up custom domain for CloudFront. The individual step-wise illustration of the process to set up a custom domain for CloudFront provides adequate clarity with the support of screenshots.
Also Read: Top 10 AWS Tips and Tricks
Setting Up Custom Domain for Amazon CloudFront
If you are wondering how to set up custom domain for CloudFront, then the process isn’t too difficult. CDN can help in easily setting up custom domain for CloudFront. Only two steps can help in achieving the objective. The two steps are:
- Serving DNS from Amazon Route53.
- Obtaining CloudFront custom domain SSL.
Obtaining an SSL Certificate
Every user should upload their SSL certification to AWS for completing the setup in CloudFront. However, let us find out the process to obtain the CloudFront custom domain SSL as follows.
- Log into the AWS console and then select the “AWS Certificate Manager.”
- You should use the region selector on the top right section to switch your location to the US East (N. Virginia) region. Why? Because CloudFront can work only with certificates created in that particular “global” region.
- Select the “Get Started” button, and then you can find the prompt for entering the first domain.
- Now, enter the domain and possible subdomains for which you want to obtain the SSL certificate.
- Click on the “Review and request” button and then on the “Confirm and request” button.
- You would receive an authorization email shortly afterward, like the one in the image below.
- After providing the approval in the authorization mail, you can have the certificate ready to use.
Thinking to move to AWS professional? Here are the top AWS Services of the year that you should know about.
Adding the SSL Certificate to CloudFront
The next important step in the configuration of the custom domain for CloudFront is the addition of the SSL certificate to CloudFront.
- You can start by opening the CloudFront console page, followed by selecting your distribution.
- Now, you can click on “Edit” and then add the custom domain to the “Alternate Domain Names” option. The alternate domain CloudFront is also known as CNAMEs.
- You should also modify the “SSL Certificate” option to “Custom SSL Certificate” and then choose the previously created certificate from a drop-down list.
- Note the unique CloudFront URL and then log into the DNS control panel.
- Add a new CNAME or alternate domain CloudFront entry pointing towards your CloudFront domain. Users have to note that the entry, in this case, should be the same as that entered in “Alternate Domain Names” in the CloudFront console.
Uploading SSL Certificate to AWS
After completing the above steps, it is essential for users to upload their SSL to AWS for the setup of a custom domain for CloudFront. You can use the following command for uploading the SSL certificate to AWS.
aws iam upload-server-certificate –server-certificate-name
myServerCertificate –certificate-body
file://public_key_cert_file.pem –private-key
file://my_private_key.pem –certificate-chain
file://my_certificate_chain_file.pem
The final step involves mapping the domain to CloudFront. You can create a CNAME record in Route53 and then link it with the CloudFront URL you want. Now, you can use your own domain name, such as cdn.mydomain.com rather than xyz.cloudfront.net.
Don’t let AWS bills make a hole in your pocket. Here are the 8 ways to reduce your AWS bill.
Conclusion
The above-mentioned steps can provide detailed guidance on how to set up custom domain for CloudFront. However, you should also look at some of the essential measures after configuring your own domain for CloudFront. For example, you have to test the alternate domain name by creating some test links. The test links should use the domain name in the URL rather than the CloudFront domain name for concerned distribution.