skip to content
Logo Rabbit Holes
A rabbit running away from a white triangle

Reinventing the wheel - Self-hosting a blog

/ 2 min read

Table of Contents

The Why

I wanted starting a blog to be more than just writing — it was a way to get my hands dirty with servers. Sure, tools like Vercel, Netlify, or even Coolify automate the whole process, and they’re great at it. But I wanted to keep it simple: just a Caddy server serving clients static HTML files. No crazy pipeline, no GitHub Actions. Work locally, deploy with a single command when you feel like it.

I also try to figure things out on my own before reaching for AI. The result might not be the most optimal setup, but that’s not the point. The point is understanding what I’m building, not just shipping it.

The How

This won’t be a tutorial on how to set up a server. My assumption is that you have a machine running and capable of reaching it via the network. My starting point is the Proxmox Caddy LXC container from the community scripts.

Caddy setup

Create a user to ssh into container, probably go through web console, give that user sudo permissions.

Terminal window
adduser yourname
usermod -aG sudo yourname

Even though this server is only accessible from within my network, I don’t think password-based SSH login is good practice in my opinion. Create an ssh key from your development machine, then copy it to your server. Then only allow login via ssh.

Create folder with appropriate permissions on server. The w flag will let group members write to the directory, the s flag will make sure created files inherit the caddy group id.

Terminal window
sudo mkdir /var/www/blog
sudo chown caddy:caddy /var/www/blog
sudo chmod g+ws /var/www/blog

Add your user to the caddy group

Terminal window
sudo usermod -aG caddy yourname

Add content to Caddyfile at /etc/caddy/Caddyfile

:80 {
root * /var/www/blog
file_server
}

Make sure to reload caddy after doing so.

Terminal window
sudo systemctl restart caddy

You now have a setup which will let your user copy files over to the /var/www/blog directory, and let Caddy run too.

Deploying

Now, the only thing we need to do is to define our build and deploy process. That’s handled easily with a quick bash script.

#!/bin/bash
set -a
source .env
set +a
echo "Build destination: $SERVER_PATH"
pnpm install
rm -rf dist/
pnpm run build
rsync -rlvz --delete ./dist/ $SERVER_PATH

And there you go! That’s it — a simple process to self-host a blog on a minimal machine. Just run your script whenever you want to publish changes to your site.