CDN hosting CloudflareI have been a fan of Cloudflare’s CDN and DNS service.   I have only used the free and pro level services but I have never had a problem until about 3 weeks ago.  Everything seems back to normal but I was annoyed when visitors were receiving a detailed error message showing that a larger site that I manage was mis-configured.  I believe it was just a bad gateway return code but their graphic places all the blame on the customer’s end.  The problem with the message is that the servers were working fine (I would be okay with the message if I was responsible).  The solution to the problem was simply shutting off their services and waiting for the dns cache to expire.

This event led to experimenting with shutting of the Cloudflare service to the main domain but have the images flow through the Cloudflare proxy.  This split is common with most CDNs – normally including other static files as well.

I made a very quick WordPress plugin that changes all my in post/page images to the CDN url.  If there is another issue with Cloudflare, I can deactivate the plugin and the images load from the normal host.  The plugin is limited but something anyone can build on.

For this site, I created a DNS record for images-cdn.thomasloughlin.com and added a server alias in my Apache2 config file pointing to the same root as thomasloughlin.com so the image paths will be the same after the domain.

The code at GitHub.

 


Leave a Reply