|« PreviousNext »|
|Did this page help you? Yes | No | Tell us about it...|
In CloudFront, an alternate domain name, also known as a CNAME, lets you use your own domain name (for example,
www.example.com) for links to your objects instead of using the domain name that CloudFront assigns
to your distribution. Both download and streaming distributions support alternate domain names.
When you create a distribution, CloudFront returns a domain name for the distribution, for example:
If you were to use the CloudFront domain name for your objects, the URL for an object called
/images/image.jpg would be:
If you want to use your own domain name,
www.example.com, for the URLs for your objects instead of the
cloudfront.net domain name that CloudFront assigned to your distribution, you can add an alternate domain name
to your distribution for
www.example.com. You can then use the following URL for
Note the following restrictions on using CNAMEs:
By default, you can add a maximum of 10 alternate domain names per distribution. To request a higher limit, go to http://aws.amazon.com/cloudfront-request/.
You must have permission to create a CNAME record with the DNS service provider for the domain. Typically, this means that you own the domain, but you may also be developing an application for the domain owner.
You cannot add an alternate domain name to a CloudFront distribution if the alternate domain name already exists in another CloudFront distribution, even if your AWS account owns the other distribution.
The DNS protocol does not allow you to create a CNAME record for the top node of a DNS namespace,
also known as the zone apex. For example, if you register the DNS name
example.com, the zone apex is
example.com. You cannot create a CNAME record for
example.com, but you can create CNAME records for
newproduct.example.com, and so on.
CloudFront doesn't support alternate domain names with HTTPS. For more information, see Alternate Domain Names (CNAMEs) and HTTPS.
The following task list describes the process for using the CloudFront console to add an alternate domain name to your distribution so you can use your own domain name in your links instead of the CloudFront domain name that is associated with your distribution.
You can also update your distribution using the CloudFront API:
To update a download distribution, use the
PUT Distribution Config API action.
For more information, go to PUT Distribution Config in the
Amazon CloudFront API Reference.
To update a streaming distribution, use the
PUT Streaming Distribution Config API action.
For more information, go to PUT Streaming Distribution Config
in the Amazon CloudFront API Reference.
Process for Adding an Alternate Domain Name Using the CloudFront Console
Sign in to the AWS Management Console and open the Amazon CloudFront console at https://console.aws.amazon.com/cloudfront/.
In the CloudFront console, update your distribution to include your domain name as an alternate domain name in the Alternate Domain Names (CNAMEs) field. For more information, see Listing, Viewing, and Updating CloudFront Distributions.
In the CloudFront console, on the General tab for your distribution, confirm that the status of your distribution has changed to Deployed. If you try to use an alternate domain name before the updates to your distribution have been deployed, the links you create in the following steps might not work.
Using the method provided by your DNS service provider, add a CNAME resource record set to the hosted zone for your domain. This new CNAME resource record set will redirect DNS queries from your domain (for example, www.example.com) to the CloudFront domain name for your distribution (for example, d111111abcdef8.cloudfront.net). For more information, see the documentation provided by your DNS service provider.
If you're using Route 53 as your DNS service, go to Creating, Changing, and Deleting Resource Record Sets in the Amazon Route 53 Developer Guide for information about how to add a CNAME resource record set.
If you already have an existing CNAME record for your domain name, update that resource record set or replace it with a new one that points to the CloudFront domain name for your distribution.
In addition, confirm that your CNAME resource record set points to your distribution's domain name and not to one of your origin servers.
Using dig or a similar tool, confirm that the CNAME resource record set that you created in Step 4 points to the domain name for your distribution. For more information about dig, go to http://www.kloth.net/services/dig.php.
The following example shows a dig request on the images.example.com domain, as well as the relevant part of the response.
[prompt]> dig images.example.com ; <<> DiG 9.3.3rc2 <<> images.example.com ;; global options: printcmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 15917 ;; flags: qr rd ra; QUERY: 1, ANSWER: 9, AUTHORITY: 2, ADDITIONAL: 0 ;; QUESTION SECTION: ;images.example.com. IN A ;; ANSWER SECTION:
images.example.com. 10800 IN CNAME d111111abcdef8.cloudfront.net.... ...
The line in the Answer Section shows a CNAME resource record set that routes queries for images.example.com
to the CloudFront distribution domain name d111111abcdef8.cloudfront.net. The CNAME resource record set is configured correctly
if the name on the right side of
CNAME is the domain name for your CloudFront distribution.
If that is any other value, for example, the domain name for your Amazon S3 bucket, then the CNAME resource
record set is configured incorrectly. In that case, go back to Step 4 and correct the CNAME record to
point to the domain name for your distribution.
Test the alternate domain name by creating some test links that use your domain name in the URL instead of the CloudFront domain name for your distribution.
In your application, change the links for your objects to use your alternate domain name instead of the domain name of your CloudFront distribution.