Reliability 7 min read

How this blog is built

A static Hugo site on a small home server, behind a Cloudflare Tunnel. The design, why I chose it, how it runs, what broke on the way and how I tuned it.

In the first post I promised to describe how this site runs. Here it is. It is a small setup, but I built it like a production service on purpose. I hosted it myself because I wanted to learn the whole path from a text file to a page on the internet.

I will stay on the level of design. No addresses, no names of machines, no rules. A blog about reliability should not be a guide for attacking its own server.

The requirements

Before I wrote any code, I had a few simple requirements:

  • the site must be static, no database, no admin login on the web server,
  • nothing in my home network should be open to the internet,
  • every change goes through a pull request, the same as at work,
  • if something breaks, I can go back to the previous version in a minute,
  • the server must not need my attention every week.

What I chose and why

A static site with Hugo

A static site has very little to attack. There is no login page and no plugins to update all the time, the server only sends files. Hugo is one binary, it is fast and posts are plain Markdown files in Git. So the history of every change is in the repository, and a pull request works the same for a post as for code.

Build in GitHub Actions

The build runs on every merge and the result goes to a separate branch that holds only the finished HTML. My server never builds anything, it only gets the result.

A VM at home, in its own network segment

The server is a Linux VM on a Mac at home. I did not want the web server in the same network as my personal devices. So only the VM sits in an isolated segment. The Mac itself stays in my normal network. From the home side only my admin machines can reach the VM.

Cloudflare Tunnel, no open ports

The tunnel opens a connection from the VM out to Cloudflare, and the visitors come through that connection. Nothing on my router is open for this site, and my home IP is not in DNS. The domain is with Cloudflare too, so DNS, TLS and the tunnel are in one place.

Pull-based deploy

The server asks for new versions, nobody pushes to it. This way GitHub needs no access to my server at all, and the server has only a read-only key to the published branch. If somebody gets into my GitHub account, they still cannot log in to the server.

How it runs

Diagram: visitors reach Cloudflare over HTTPS. A Linux VM in an isolated segment on a Mac at home opens an outbound tunnel to Cloudflare. GitHub Actions builds the site into a published branch, and the VM pulls it with a read-only key. Only admin machines reach the VM from the home network.

When I merge a pull request, GitHub Actions builds the site with Hugo and publishes it to the separate branch. The VM checks every few minutes if there is a new version, downloads it and switches to it. If a build is bad, I revert the merge and the VM pulls the previous version back.

Inside the VM, Caddy serves the files and runs in Docker, and the Cloudflare Tunnel runs next to it. Caddy also sends strict security headers, including a Content Security Policy that allows only scripts and styles from the site itself. The VM installs security updates on its own, so the requirement “no attention every week” is met for the boring part.

While the texts were not finished, the site was online but marked as noindex everywhere. The build even fails if a placeholder text is left in the site with the real domain set. I switched indexing on only after the first post was published. This guard is boring, but a half-finished site cannot end up in search results by mistake.

Troubleshooting

I locked myself out

The first real problem was mine. When I switched SSH on the VM to keys only, my first try did not work and I could not log in anymore. A small setting, a few seconds of work, and the server was closed for me as well. I had to roll the change back and do it again. The second time I went step by step and kept a working session open until I was sure the new access works. Now SSH accepts only keys.

I have seen the same thing in real changes many times. The change itself is easy, but nobody tests how you get back in when it fails.

The VM in its own network

Putting only the VM into the isolated segment, and not the whole Mac, took some trial and error. The network side was simple. Getting the virtualization software to bridge the VM to that segment, without giving the Mac an address there, needed a few attempts. It works now, and I like that the Mac and the VM are in different trust zones even though they are the same box.

My own security policy broke the page

The Content Security Policy is strict, so it blocks inline styles. Once a new part of the page had a small style written directly in the HTML, and the browser simply ignored it. The page looked wrong and there was no error you would see without the developer tools. The fix was to move the style to the CSS file. I was a bit annoyed, but the rule did exactly what I wanted from it.

Google remembered a site from 2016

When I added the domain to Google Search Console, it already had a sitemap from 2016. The domain had an owner before me, and Google still remembered their site. I removed the old sitemap and sent the new one. Also, Google kept an old copy of my robots.txt from the time when the site was hidden, so for a day it reported the site as blocked. Nothing to fix there, only wait.

Tuning

Design and readability

The design went through several versions. The final one is built around a storage enclosure: a rack rail on the side, a disk array in the header, and a “failure drill” where you can fail a disk and watch the rebuild. In the background there is a heartbeat line, like on a monitor.

When it was almost done, I asked a few senior colleagues for feedback. They recommended some changes and I made them. One of them was readability: the background now fades out behind the text column and stays visible only at the sides.

Speed

Every design change was checked in Lighthouse. Animations are expensive, so the background starts only after the page has loaded. I also fixed the contrast of a few small labels. With this the scores are between 98 and 100 on mobile and desktop.

External data

The sport section shows my yearly totals from Strava. They are not loaded in the browser. The build asks Strava for the numbers every night and writes them into the site. If Strava does not answer, the build keeps the last numbers and continues. The page never waits for an external service, and an outage on their side does not become an outage on mine.

Working with AI

I built most of it with AI and the 20-60-20 approach from the first post. I set the requirements and the rules, AI wrote the code, and I reviewed every pull request before merge. In the first four days that was more than 40 pull requests.

It was much faster than doing it alone. It also made mistakes, and some changes I simply did not like. AI was good at the 60 %, but it did not know my network or my taste. That stayed my job.

What I learned

  • Before you change access, make sure you have a way back in.
  • Guards in the pipeline are cheaper than fixing a mistake in production.
  • An outbound tunnel and a static site remove most of the attack surface before you start hardening.
  • External data should never be able to stop your own service.
  • Measure after every change, even a small design change can cost speed.
  • Ask someone else to look at it. You stop seeing your own problems.

None of this is new. I know all of it from work. But doing it on my own small server, where every mistake was mine, made it stick better than any training.