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:
Create a Pull Zone for the root domain (e.g.
example.com
) or subdomain (e.g.origin.example.com
).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
).Add a Zone Alias for the subdomain created in step 2 (e.g.
www.example.com
).From the KeyCDN dashboard, navigate to your Zone's settings. From here, configure the following settings:
- Expire setting to
0
- Ignore Cache Control setting to
disabled
- Forward Host Header setting to
enabled
- Strip Cookies setting to
disabled
- Canonical Header setting to
disabled
- Generic Error Pages setting to
disabled
- Expire setting to
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, settingproxy_hide_header Vary;
andproxy_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.