Support

Find answers, guides, and tutorials to supercharge your content delivery.

Create a Zone Alias

Updated on February 11, 2020
Create a Zone Alias

The Zone Alias configuration always requires a CNAME record to be added in your DNS in addition to adding the Zone Alias in the KeyCDN dashboard. The Zone Alias grants access to your Zone by activating the specified domain on our network. The CNAME enables the domain name resolution to your Zone and is responsible for pointing your Zone Alias (e.g. cdn.example.com) to the Zone URL (e.g. example-1a2b.kxcdn.com).

  1. Add a CNAME record in your DNS. This will be your desired Zone Alias that points to your Zone URL. For example, create cdn.yourwebsite.com as a CNAME record that points to example-1a2b.kxcdn.com. Check that your new DNS record is active with our DNS Checker tool. Please keep in mind DNS changes can take some time depending on the TTL.
  2. Log in to the KeyCDN dashboard.
  3. In the left navigation sidebar click Zone Aliases.
  4. Click Add Zone Alias.
  5. Define the Zone Alias that matches the CNAME record created in step 1 (e.g cdn.yourwebsite.com).
  6. Choose the Zone that you want to map the Zone Alias to.
  7. Click Save.

Here is an example for what it may look like for static resources on your website:

Without CDN:

<img src="https://www.yourwebsite.com/img/example.jpg">

With CDN:

<img src="https://example-1a2b.kxcdn.com/img/example.jpg">

With CDN and Zone Alias:

<img src="https://cdn.yourwebsite.com/img/example.jpg">

Commonly, a 403 error will be returned if a CNAME record has been created but the corresponding Zone Alias has not been added in the KeyCDN dashboard.

Wildcard Zone Alias

Defining a wildcard Zone Alias, such as *.example.com, will allow more than one subdomain to be pointed towards a Zone URL, for example:

  • img.example.com
  • css.example.com
  • js.example.com

Remember to add a CNAME record to your DNS settings to point the wildcard Zone Alias to the Zone URL.

Pointing root domains to your Zone URL

CNAME records are not supported on root domains (e.g. example.com) as they would conflict with the SOA and NS records (RFC1912 section 2.4: "A CNAME record is not allowed to coexist with any other data."). An alternative option is to redirect the root domain to a subdomain (e.g. www.example.com). Do the following in your DNS settings:

  1. Redirect your root domain to its www version with a URL or Forward record.
  2. Create a CNAME record for www and point it to your Zone URL.

Some DNS providers do not support redirects (known as URL or Forward records). An alternative option would be using use the free service wwwizer.com. We recommend to avoid this approach as it negatively impacts performance and generates additional RTTs. Use subdomains instead.

There are DNS providers offering better solutions to this problem such as NS1. They call it ALIAS records (NS1) or CNAME Flattening (Cloudflare). This allows the root (naked) domain to be pointed to a Zone URL. It is important to note that the CNAME record will be masqueraded as an A record.

Advantages of using a Zone Alias

There are a few advantages to setting up a Zone Alias as opposed to using the KeyCDN Zone URL provided in the dashboard.

  • Using a Zone Alias allows you to setup a generic subdomain such as cdn.yourdomain.com, allowing you to keep the same URLs even if you point your CNAME record to a different URL in the future (e.g. if you want to change CDN providers).
  • The domain will contain keywords relevant to your site, therefore your assets are closer bound to your domain which is better in terms of CDN SEO.
  • Using a Zone Alias allows you to take advantage of Let's Encrypt, which provides you with a custom SSL/TLS certificate for free.
  • Zone Aliases allow you to view indexed images data using the sitemap view in Google Search Console.

Disadvantage of using a Zone Alias

Since Zone Aliases are created using a CNAME, this produces an additional DNS lookup. However, if you set your DNS TTL high enough (e.g. greater than 3600) there should be little to no affect on speed.

KeyCDN uses cookies to make its website easier to use. Learn more about cookies.