Manage multiple websites with one Zone

There are different options for managing multiple websites with KeyCDN. In this article we’re highlighting the two common approaches.

Option 1: Using one zone per website

The standard setup is one zone per website. Each zone will have its own URL.


Each zone has its own origin URL

Facts of having one zone per website:

  • Each zone (website) can be purged separately
  • Statistics are available for each zone (website)
  • Each zone needs to be setup and maintained individually
  • More than 3 zones will cost $1/zone/month

Option 2: Using one zone to manage multiple websites

An alternative approach is to manage multiple websites with one single zone. We recommend this approach if you plan to deploy multiple websites with the same zone settings. It is important to note that this setup requires a configuration change on the origin server as well.


There’s only one zone and one zone URL

Each request from KeyCDN to the origin server contains the HTTP header X-Forwarded-Host (XFH) as shown below in the sample request. XFH contains the zonealias of each request. Based on XFH, the origin server needs to deliver the right assets for this particular zonealias (see code snippets below on how to configure the origin server). The pull zone will maintain a separate cache for each XFH.

Things to be aware of having multiple website in the same zone:

  • No need to setup multiple zones
  • No charges for additional zones
  • The zone can be purged as a whole or each file separately but not a single website
  • Statistics are available for the whole zone but not each website

Implement one zone for multiple websites

  1. Enable the “Cache Key Host” option in your zone’s advanced features section. cache key host enabled
  2. Create Zonealiases for each of your websites that you’re planning to use.
  3. Modify your origin server in order to manage X-Forwarded-Host (XFH).

    location / {
        if ( $http_x_forwarded_host = ) {
            root /path/to/website/alias1/;


     RewriteEngine on
     RewriteCond "%{HTTP:X-Forwarded-Host}" "alias\.example\.com" [NC]
     RewriteRule "^(.*)$" "/sub/path/$1" [PT]
  4. Test your setup. Once you’ve modified your origin server, test if the origin server is returning content as expected.

Each request from KeyCDN to the origin server contains the HTTP header X-Forwarded-Host

GET /foobar.jpg HTTP/1.1
Host: your_origin_host
X-Forwarded-Host: <zonename>-<id>
X-Forwarded-Scheme: http
X-Pull: KeyCDN
Connection: close
Accept: */*
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36
Accept-Language: en-US,en;q=0.8,de;q=0.6,ja;q=0.4
Cookie: foobar