Hosting Ghost for (almost) nothing

How to host a Ghost blog, with domain, and TLS for around £10/year.

If you've always wanted to host your own blog, but weren't sure where to start or worried about how much it would cost then this post is designed to help you! It explains how I took my blog costs from around £355/year to around £10.

This blog is written using Ghost, which is my favourite free blogging platform. It's incredibly simple, and if you're a developer like me then you will be right at home writing your posts in Markdown.

Where I Started

When I first started hosting my own blog I ran it on a single Virtual Machine on Amazon Web Services, I paid for SSL certificates as well as my domain, and my costs were something like:

  • £25/month for compute costs (Virtual Machine, Egress traffic etc)
  • £15/year for karlstoney.com
  • £40/year for my SSL certificate

So we're looking around £355/year. Ouch. It was also quite complex, I had to manage that VM, keep it patched and up to date. I had NGINX in front of the blog as a reverse proxy, and then I ran a 0.11.something version of Ghost in a Container.

When LetsEncrypt became mainstream, you could suddenly get free SSL certificates (on a 3 month rolling expiry). If you read my Securing your Website post, then you'll have seen how I integrated that into NGINX in an automated fashion. Saves me £40/year anyway!

Where I am now

I don't blog as much as I used to, so the content on the site doesn't change a whole lot. Therefore I decided that I don't actually need a "live" version of Ghost on the internet, instead I could just use Ghost locally to write my content and then generate an entirely static version of the site by crawling it.

The idea was if I could generate the static content easily enough then I could just put it into an S3/GCS bucket, both of which support "websites" now (eg they will display index.html at a folder route), and then I could point my domain at those instead. No need for complicated compute.

Running Ghost Locally

The first thing I needed to do was get up to date with Ghost, I was two major versions out of date, and I also wanted it to be very easy to spin up locally. So I wrote ghost-static, which is a Docker'd version of Ghost with persistent on-host storage. Give it a go yourself, simply clone the repo and do docker-compose build, followed by docker-compose up:

And there you go, a fully working up to date version of ghost. Just start editing. All your data will be persisted to your local machine.

Generating the Static Content

So you've started a blog, you've created some content, and now you want to make it live. Fortunately someone else had the same idea as me and wrote a handy little utility to generate static versions of Ghost blogs. You can go and give it a go yourself if you want to host your static content elsewhere, but below is how I sync it up to my static bucket.

Hosting the Static Content

I personally use Google Cloud for my compute, so that's what this article will talk about. Head over to Google Cloud and create an account (free) and login. You'll need to create a Google Cloud Storage bucket which is public, and has "website" configured. Check out the documentation here for how to do it.

Once you've done that, make sure you have the Google Cloud SDK installed, and authenticated, because the next step will use the command line to upload a static version of your site.

In another window, simply run docker-compose exec app /usr/local/bin/generate_static_content.sh, this will crawl your website, generate the static content and sync it to the GCS bucket named the same as your domain (in my case, karlstoney.com). It takes around 10 seconds to run and upload for this website... not a lot of time at all.

Pointing your Domain at a bucket

Both AWS S3, and GCS support pointing custom domains at buckets. For GCS, simply create a CNAME record pointing to the GCS domain:

And that's it, you'll now only be charged for bucket data egress, which is pittance. However I wanted to go one step further. Cloudflare offer a brilliant all-in-one service for free for individual users. Head over there and register, and you get:

  • DNS management
  • WAF/Firewall to prevent malicious attacks
  • SSL certificate generation and management
  • CDN Caching (reduces the number of requests to your bucket, more cost saving)
  • And (coming soon, but you can register) "at cost" domain registrar, so karlstoney.com costs me about $8/year

Wrapping it up

Domain at about £6/year, and about £4/year for my GCS bucket traffic. Not bad really!