| « | Ghost on a Raspberry Pi |
For over three years now I've been running a weekly blog for my councillor work over on Substack. You can find it by going to paul.nairn.scot.
Substack has its plus sides, not least that it's free - which suits me as I'm not charging subscribers so I make no income - but it also has its critics for political reasons (they host blogs for nazis). Plus they can pull your blog for arbitrary reasons and their customer support sucks.
So I've been looking at alternatives and Ghost is widely recommended. Their business model is different to Substack as they charge all bloggers rather than taking a cut from bloggers who charge subscribers.
They charge $15 per month initially but that goes up to $29 per month if you have over 1000 subscribers (and $199 a month if you have over 10,000).
The plus side however is that Ghost is Open Source and you can host it yourself so I've done that, using a Raspberry Pi 4 model B which comes with 8GB of RAM and a 32GB micro SDHC card.
It's pretty straightforward to do but here's some notes, both for you and me. Make sure you read 4(c) before committing too much time to this as it's a biggie and may stop you in your tracks.
- Details of how to install Ghost can be found here and I chose Ubuntu but used 24.04 LTS not 22.04 LTS and it worked fine doing that.
- From a technical point of view the way it works is that it uses Node.js to do the grunt work. That listens on port 2368 on localhost. Sitting in front of that is NGINX listening on ports 80 and 443 as usual and acting as a proxy. All of this is set up for you if you follow the installation instructions and on my Pi it now thinks the blog is http://books.ghost (which resolves to the Pi thanks to our DNS server).
- I'm running this at home on static IP over 910/109Mbps FTTP (thanks Zen) and ports 80 and 443 are forwarded to our web server which runs Apache so when you go to aboutabook.uk on HTTPS Apache proxies it off to the Raspberry Pi as http://books.ghost and NGINX then proxies in on to Ghost.
- This all pretty straightforward stuff but here's the interesting parts:
- Apache proxies1 to the Pi via two directives in the site config thus:
ProxyPass "/" "http://books.ghost/" ProxyPassReverse "/" "http://books.ghost/"but when NGINX proxies on to Ghost by default it does it on port 80, which is what the request has come in on. Ghost then sends a '301 Moved Permanently' redirect to https://books.ghost and this fails as there's no HTTPS version of the site (because I didn't want to faff about with this on a machine which isn't world visible2). The solution is to update the proxy header directive in the NGINX site config thus:
# proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Proto https;So that's saying to Ghost "this request came over HTTPS, we're just passing it to you via HTTP but don't you worry your pretty little head about that".
- You can set up Ghost to send mail through whatever route you choose and here's the lines you need in
config.production.jsonto do that using your own SMTP server:"mail": { "from": "'your_name' <your_email_address>", "transport": "SMTP", "options": { "host": "your_SMTP_server", "port": 587, "secure": false, "auth": { "user": "username", "pass": "password" } } - However, and this is a huge however, you cannot send your blog out to subscribers via any method except Mailgun. This was a huge blow when I discovered it as they charge. All is not lost however, they offer a free account which they say lets you send 100 emails per day but is actually 3,000 per month.
I'm not sure if you can send 600 on five days in the month but I suspect you can as they seem to work on mails/month everywhere else. Their "Basic" plan offers 10,000/month for $15.
Anyway for now as I currently have two subscribers to aboutabook.uk, both of which are me, this is not a problem so I've configured Ghost to use Mailgun following their instructions.
- Apache proxies1 to the Pi via two directives in the site config thus:
| Tags: blogging, linux, websites | Written 12/07/25 |
| « |


