For about 6 years or so, I have hosted a set of very small websites, including this one, on Netlify. I found it very easy to use, since you just push to a github repo and boom! Your web site is updated in a few moments with the same content. And Netlify very kindly offers a free tier for small time users like me. (If you’re reading this, you’re part of a very small group, so thank you!) I use Hugo to build my static web sites, so the content on Netlify is just a lot of static files - html, css, javascript and a bunch of images for the most part. That all worked just great until just recently, when I learned that Netlify was using Amazon Web Services under the hood, to host their account contents. I am not a fan of Amazon (the company) so this became a problem. Also, I am moving my code off of github, for similar reasons. So I needed a new solution to running my sites. It had to be cheap, not hosted by Amazon or any of the other big tech firms (so a free Oracle server is not an option), and I had to be able to control it entirely myself.
To replace netlify, I would have to:
Find a web host who could easily and cheaply host my little collection of static files. This is easy, as they all can handle my data and my very low bandwidth requirements.
Find a way to easily set up SSL certificates for my sites, so they can be reached with “https:” instead of just “http:”. This was automatic with Netlify but I would need to find another solution now.
Find a replacement for Netlify’s free forms handler, which is how I encouraged people to contact me in the past. That feature of Netlify was great and blocked spam and such, without me having to code anything / host a database.
After fishing around for options, I settled on a Virtual Private Server (VPS) hosted on Hetzner (Wikipedia page), a German company known for square dealing and receiving many positive reviews from techies like me. Signing up for Hetzner was easy and the cost is affordable - $4.09 for their lowest power server offering (CX23 if that helps).
I’ve wanted to check out Caddy, a web server-slash-reverse proxy app for a long time, so this seemed like the perfect opportunity. It hosts any web site, and sets up SSL certificates automatically (relying on Let’s Encrypt) so that’s a big help. And configuring the Caddyfile (as its configuration file is called) was dead simple, very easy to learn in a short while.
Here are the steps I followed, if this helps anyone else kick the habit and move to self-hosting:
Sign up for Hetzner. Deal with payment.
Create a new server, selecting the region, performance options (CPU, Storage, RAM) - which in my case, is all the lowest options they offer.
Create a SSH key for use with Hetzner on my PC. Upload the public key to my Hetzner account.
Login from a terminal with SSH and my key. I created a (username)/.ssh/config file on my PC so I could refer to the server as just “hetzner” from now on too.
Login using SSH and install Caddy.
Follow the Quick Start Guide in their documentation to see how it works. At first, this was just using the server’s IP address, since I hadn’t setup any domain names yet.
Yup, there’s a generic “Hello world” web page running now at my server’s IP. Cool!
Then, deploy the “public” folder from my local copy of the web site’s Hugo folder, to the Hetzner server. The Hugo documentation has this great page for setting up. In the end, I just run a “deploy-to-hetzner” sheel script on my PC and that copies the changed files to the server for me.
That worked, so now all my web site’s public files are on the server.
Set up the Caddyfile to point my domain name to the folder with those files. This is all it took to make this happen:
www.peterries.net, peterries.net: {
root * /root/peterries.net-2
encode
file_server
}
The first line says, “when requests hit the server with those URLs, serve up the files found in that “root” path. Encode the files in responses. So simple!
Go to my domain name server (Porkbun, if you’re curious), and change the A and AAAA DNS records to point to my Hetzner server, instead of Netlify. Wait a while since this kind of change takes time to “propogate” across all the DNS servers around the world. I think this took around 4 hours to get all caught up. (Check your DN server’s documentation; they all support either directing your traffic to some other Name Server, or setting up specific DNS records in their system)
Check the DNS propagation status with a tool like this one at whatsmydns. Select the A or N S record type and see what the results show. When you see your new DNS entries showing up, you know the propogation is working.
Wait some more, then boom it just starts working. When you visit peterriesn.net now, your getting served by Hetzner, using Caddy in the back end. That service has a SSL certificate, auto-magically.
To replace the contact form, I decided I would use another free cloud service called CommentBox. I’d already started using it on the free tier (100 comments per month) for commnents on one of my other web sites, so now they all support that feature and that’s the best way to concat me now. You just sign in somehow (many options) and leave me a comment. I get an email, and approve it or reject it.
I have more I want to do to make this nicer and to offer more features over time. For instance, I might try to host my own comment service on the Hetzner box sometime soon. But generally, this was not too hard, and only took me a few hours, spread out over a weekend. I am happy with the service on Hetzner and glad I started to learn how Caddy works.
Cheers, self-hosters, till next time.