Support

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

Ghost CDN Integration

Updated on March 30, 2021
Ghost CDN Integration

Ghost is an open source publishing platform released in 2013 and is developed by Ghost Foundation, a nonprofit organization, and a community of open source contributors from all over the world. It is intended for professional publishers wanting to build and run modern online publications.

Once you have setup your Ghost powered website, you may want to further accelerate your content delivery. Adding a CDN to your Ghost application will bring your content as close as possible to your users, decreasing the overall latency of your application. After integrating KeyCDN your content will be delivered from our closest available network POP.

How to complete a Ghost CDN integration

This integration guide demonstrates how to complete a Ghost CDN integration with KeyCDN. Follow the steps below to successfully integrate your Ghost publishing platform on Nginx with KeyCDN:

  1. Create a Pull Zone for the root domain (e.g. example.com) or subdomain (e.g. origin.example.com).

  2. Create a CNAME DNS record that points your preferred subdomain (e.g. www.example.com) to your Zone URL (e.g. examplepull-hexid.kxcdn.com).

  3. Add a Zone Alias for the subdomain created in step 2 (e.g. www.example.com).

  4. From the KeyCDN dashboard, navigate to your Zone's settings. From here, configure the following settings:

    1. Expire setting to 0
    2. Ignore Cache Control setting to disabled
    3. Forward Host Header setting to enabled
    4. Strip Cookies setting to disabled
    5. Canonical Header setting to disabled
    6. Generic Error Pages setting to disabled
  5. Modify your Nginx configuration file to resemble the following:

    server {
        listen 80;
    
        # Use the Zone Alias added in step 3
        server_name www.example.com;
    
        location /ghost {
            proxy_hide_header Vary;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header Host $http_host;
            proxy_pass http://127.0.0.1:2368;
        }
    
        location / {
            proxy_hide_header Vary;
            proxy_hide_header Cache-Control;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header Host $http_host;
            proxy_pass http://127.0.0.1:2368;
        }
    }
    

    Configuring the above directives will disable any caching of the HTML document when file paths containing /ghost are accessed (e.g. Ghost admin). Additionally, setting proxy_hide_header Vary; and proxy_hide_header Cache-Control; will allow the HTML document to be cached for pages which do not contain /ghost.

    Note: Restart Nginx after saving the changes above.

Upon completing this Ghost CDN integration, your site (when accessed with the defined subdomain) will be fully accelerated by KeyCDN. If you do not want to deliver the HTML document through KeyCDN for any pages, simply remove the proxy_hide_header Vary; and proxy_hide_header Cache-Control; configurations from within the location / block in your Nginx configuration file. If you decide to make these additional changes, make sure to purge your entire CDN cache afterwards.

Supercharge your content delivery 🚀

Try KeyCDN with a free 14 day trial, no credit card required.

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