Create a Zonealias

create a zonealias

The Zonealias configuration always requires to configure the alias in the KeyCDN dashboard and to add the according CNAME in your DNS records. The Zonealias grants access to your Zone by activating the specified domain on the KeyCDN edge servers.

The CNAME enables the domain name resolution to your zone and is responsible for pointing your Zonealias to the kxcdn.com zone url. Commonly used Zonealiases are cdn.foo.com.

Add first the CNAME record in your DNS or you cannot add the Zonealias.
E.g. cdn.yourwebsite.com CNAME lorem-1.kxcdn.com

 

  1. Add the CNAME record in your DNS (Zonealias –> Zone URL). Check that your new DNS record is active with the DNS Check Tool. DNS changes could take some time depending on the TTL. dns-check
  2. Sign in to the KeyCDN dashboard
  3. Click on Zonealiases in the left navigation bar. Click on New Zonealias (blue button)
  4. Define a Zonealias Name of your choice (e.g cdn.yourwebsite.com)
  5. Choose the zone you want to map the Zonealias to and click on “Add”create-zonealias

Here is an example how it might look like for static resource on your website (e.g. Zonealias: cdn.yourwebsite.com, Zone URL: lorem-1.kxcdn.com):

  without CDN:
    <img src="http://www.yourwebsite.com/folderxyz/img.jpg" alt="just an example">

  with CDN
    <img src="http://lorem-1.kxcdn.com/folderxyz/img.jpg" alt="just an example">

  with CDN and Zonealias
    <img src="http://cdn.yourwebsite.com/folderxyz/img.jpg" alt="just an example">

Commonly, a 503 Zone Not Found error will be shown if a CNAME record has been added however the corresponding Zonealias is missing.

Wildcard Zonealias

If you are delivering assets from multiple subdomains on your website, for example: 

  • Images from img.example.com,
  • CSS from css.example.com,
  • JS from js.example.com

you can use a wildcard Zonealias. Defining a wildcard Zonealias such as *.example.com will allow you to easily point each subdomain towards your KeyCDN Zone url.

Remember to add a CNAME record to your DNS settings to point the wildcard Zonealias to the Zone url.

wildcard cname

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 is to redirect your root domain to a subdomain (e.g. www). Do the following in your DNS settings:

  1. Redirect your root domain to its www version with an URL or Forward record (e.g. www.example.com)
  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), instead use the free service wwwizer: http://wwwizer.com/naked-domain-redirect

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 nsone. They call it ALIAS records (nsone) or CNAME Flattening (CloudFlare), which allows to point a root domain (“naked” domain) to a Zonealias. It is important to note that the CNAME record will be masqueraded as an A record.

Advantages of Using a Zonealias

There are a few advantages to setting up a Zonealias as opposed to using the KeyCDN zone url provided in the dashboard.

  • Using a Zonealias 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 Zonealias allows you to take advantage of Let’s Encrypt SSL which provides you with a custom SSL certificate for free.
  • Zonealiases allow you to view indexed images data using the sitemap view in Google Search Console.

Disadvantages of Using a Zonealias

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

Related Articles