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 403 Forbidden 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

37 Comments

    1. Sven

      You need a Custom SSL in that case. Just switch from shared to custom and submit you certificate and private key.

  1. Ethan Waldman

    Once I set up the CNAME with my host, can I update my static content filter in Zencache to the Zone alias (instead of the zone address?)

    1. Cody

      Hi Ethan, yes you’ll want to update your Zencache with the zone alias you created once you have configured your CNAME record in your DNS.

    1. Cody

      Hi Solomon, zone aliases allow you to use a naming convention for your zone that is more relevant to your website as opposed to the default zone url. Zones aliases are also required when using custom SSL.

          1. Solomon Ndvr Kleinsmith

            I had already read that… I didn’t ask about anything that that article mentions. I’ll try to be extra clear – I have two questions:

            1) Is there any speed or SEO benefit to using a custom SSL vs shared SSL, and/or custom zone aliases?

            2) Are there any other benefits or downsides involved with using one vs the other?

          2. Cody

            1) There is no speed difference by implementing a zone alias or using custom/shared SSL. For SEO, if you have the canonical tag pointing to your origin URL there should be no difference between both options. However, it may be safer to use a zone alias just incase a Google update disrupts the functionality of the canonical tag.

            2) Using custom SSL (which needs to also use a zone alias) does have some additional advantages such as you have the ability to use the sitemap to view the indexed images data and the domain name will contain relevant keywords to your site. You can see this recent article https://www.keycdn.com/blog/cdn-seo-indexing-images/ for a more detailed explanation.

        1. Sven

          A zone alias is commonly the better option in terms of SEO. Because the assets are closer bound to your domain. Aliases adds an additional DNS lookup due to the CNAME you need to create but this is negligible if you set the DNS TTLs high enough (I would say >3600 seconds).

  2. Dr. Ohad Hershkovitz

    After creating the zonealias do we need to update asset links in our website to get them to point to the cdn? Currently all references/links are relative e.g. “/images/xxx.jpg”

  3. solagratia_r

    Have question on Wildcard Zonealias, can you provide detail setting requirement?
    Do we need to add .htaccess setting in our side?

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

    1. Sven

      Adding rules in your .htaccess file is normally not required. Just open a support request if you have very specific questions to your setup.

  4. Michael Conradsen

    I have a question about Zonealias’s – are there any benefits to using a zonealias instead of not bothering to set it up?

    1. Cody

      Hi Michael, this was addressed a little further down in the comments. The main benefit of setting up a Zonealias would be for SEO purposes since the assets are closer bound to your domain.

  5. Sam

    Hi KeyCDN, I love the affordability of your services and am trying to set things up, but there is one huge problem holding me back from setting up a KeyCDN account for my wordpress site- the instructions are too technical. I have zero knowledge on technical things and cannot understand instructions loaded with technical terms. Really hope to see some change soon! In particular, I am trying to set up KeyCDN with CloudFlare, and the instructions prove to be too tough for me. [https://www.keycdn.com/support/setup-cdn-with-cloudflare/]

  6. James

    how long will it usually take for me to see cdn.domain.com to take effect?
    i’ve followed the guide, setting up the zonealias and adding cname to cloudflare.

    do i need to change the CDN URL in CDN Enabler plugin? to cdn.domain.com? or just leave it as is?

      1. James

        yup, cname is greyed.

        i was waiting for it to take effect and then i realized how will my website use the zonealias if it’s not pointing there (via the plugin). so, i changed it, now it’s working fine. thanks!

    1. Cody

      Yes in most DNS settings the hostname must end with a dot. I have updated the wildcard CNAME screenshot to reflect this.

    1. Angel Cárdenas

      i cant use *.example.com as a wildcard because i use some subdomains for email, etc.
      do i have to use cdn.example.com? im using KeyCDN to serve my static assets in my wordpress instalation

        1. Angel Cárdenas

          i did all the steps, but i just realize that i cant use it when my website use SSL 🙁 …BTW im trying now to configure sendgrid click tracking througt KeyCDN because my website use SSL but in sendgrid told me that something is not well configured in KeyCDN

  7. EgorRevenga

    Hi, KeyCDN! I’m testing your network with my site. After creating dns record and zonealias (cdn.myownsite.com), all requests redirects to cdn.myownsite.com even if I open myownsite.com (without www). How to use default site address, not a cdn.myownsite.com?

  8. Samuel

    Hi KeyCDN, in your blog instruction .. what does “Create a CNAME record for www and point it to your zone URL mean” ?

    zone URL refers to cdn’s zone URL ? I’ve tried that approach .. and of course i got a 403 forbidden error message as the SSL doesn’t support *.kxcdn.com …

    Please advise

    1. Cody Arsenault

      Correct, the zone URL refers to the CDN’s zone URL (e.g. lorem.1c6b.kxcdn.com). If you’re creating a Zonealias you will need to enable either the Let’s Encrypt or Custom SSL options as shared SSL won’t work with a Zonealias. Please open a support request if you need further assistance: https://www.keycdn.com/support/

Leave A Comment?