Ghost CDN Integration

 ghost cdn

Ghost is an open source publishing platform for professional bloggers. Ghost offers a few variations that differentiate it from other publishing platforms such as:

  • It provides a split-screen editor that allows you to write posts in markdown on the left while being able to view a live preview on the right.
  • Ability to invite and collaborate with multiple members of your team.
  • Simple and clean UI design that allows you to browse your content in the same way you would browse your email.

However, once you have setup a website using Ghost, you may want to further accelerate the delivery speed of your static content. In this integration article, we cover the steps required to complete a Ghost CDN integration to enable your static assets to be delivered from the closest available CDN PoP.

How to complete a Ghost CDN integration

Follow the steps below to perform a Ghost CDN integration with KeyCDN. This integration guide assumes you are using Nginx.

  1. Before getting started with the integration, ensure you have created a KeyCDN Pull Zone pointing to your root domain.
  2. Create a DNS record pointing the www.yourwebsite.com subdomain (or use any other subdomain) to your KeyCDN zone URL (lorem-1c6b.kxcdn.com).
  3. Create a Zonealias for the subdomain you defined in step 2.
  4. Navigate to the advanced features section of your zone. From here, set the Expire value to 0disable “Ignore Cache Control” and enable “Forward Host Header” ghost cdn zone settings
  5. Modify your Nginx configuration file to resemble the following:
    server {
        listen 80;
        server_name ghost.keycdn.net;
    
        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:88;
        }
    
        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:88;
        }
    
    }

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

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; settings from within the location / block in the Nginx configuration file.

Upon making these changes, ensure you purge your entire zone’s cache.

Leave A Comment?