This blog is generated by Jekyll, running on Caddy HTTP/2 server, and hosted on the lowest-tier Digital Ocean “droplet” (virtual private server). Self-hosting isn’t for everyone, but if you’re the sort of person who wants complete control over your content and how it is delivered – and who might like to tinker every so often, then read on.

The basic steps to setting up are:

  1. Prepare the Droplet
  2. Install Caddy
  3. Setup Jekyll and your workflow

Thankfully for me, other people have already written up their own guides for each of these steps!

To create the droplet that will host your blog, you’ll need a Digital Ocean account. If you don’t have one already, sign-up using my referral link to get $10 in credit.

1. Prepare the Droplet

Create a new Ubuntu 16.04 droplet through the Digital Ocean dashboard, then follow this guide to initial server setup. This should give you a nice base to work with. One thing I like to add to this initial setup is Fail2Ban, which will automatically ban the IPs of connections trying to login with wrong SSH credentials (which will be anyone but you):

$ sudo apt-get update
$ sudo apt-get install fail2ban
# Fail2Ban should automatically start. Check it with the line below:
$ systemctl status fail2ban

One more thing you can do (not neccesarily required, as you setup <code>ufw</code> firewall on the server) is enable a Digital Ocean firewall from the dashboard, and limit connections to just ports <code>22</code>, <code>80</code>, and <code>443</code>.

2. Install Caddy

Installation of Caddy is covered by this guide. I followed the steps pretty much as-is, with only minorr changes to match my setup (different username, etc). The biggest difference in my setup was I installed a couple of plugins as part of my Caddy installation. To do this, change the command in Step 1 to the following:

$ curl | bash -s http.minify,tls.dns.cloudflare

This will install the Minify and Cloudflare plugins. Check out the Caddy home page for more plugins.

I set my site to use the Auto-HTTPS feature of Caddy, which gives the site a SSL certificate via Let’s Encrypt. I also wanted to use Cloudflare in front of my site, which isn’t covered in the guide above. After a bit of trial-and-error, the steps I used are below. If you don’t plan to do this, skip to Step 3.

2.1 Using Caddy Auto-HTTPS with Cloudflare

First off, you need to setup some environment variables. To do this for the Service you will have created using the guide above, run the following command:

$ sudo systemctl edit caddy

This will open up an editor for you to override or add to the main service file. In the editor, enter the following:

Environment=CLOUDFLARE_EMAIL="<CloudFlare login>"
Environment=CLOUDFLARE_API_KEY="<your Cloudflare CA API key>"

Save the file and exit. Next, edit your Caddyfile:

$ sudo nano /etc/caddy/Caddyfile

Modify to something similar to this: {
    root /var/www
    tls {
        dns cloudflare

Finally, in the Crypto section of your Cloudflare control panel, make sure to set the SSL type to Strict. If you don’t, you’ll end up with redirection errors

You should be ready to start/restart Caddy:

$ systemctl restart caddy
$ #Enter your password when prompted

All being well, your site should be available, with HTTPS enabled.

3. Set-up Jekyll and your Workflow

I followed this guide to setup Jekyll on my Droplet, and create the necessary Git components. If your local machine is OSX or Linux, the guide is all you need. If you’re running on Windows (like me) things are a little more difficult. I tried setting everything up using the Linux Subsystem for Windows, like in this guide, which is the route recommended by the official Jekyll site — but for some reason it didn’t work correctly.

I ended up having to install both RubyInstaller and add the necessary DevKit as the last step of the installation. From there, it should just be a case of gem install jekyll bundler and creating the Jekyll site in the normal manner (follow the first part of the guide linked at the start of this section if you need to).

Hopefully, if you’ve followed along this far, you should now have your own shiny new blog, hosted on your own server! Setting this up took me a single evening – not including the time I spent creating my own Jekyll layouts. But those are a topic for another time…