Dev server with Caddy
DATE : 26.02.2026
So I wanted a simple dev HTTP server. As my (self-built) static site generator does not have one built in, and I didn’t want to spend time implementing such a feature, I started looking around.
After a bit of exploratory investigation, looking at various options, I settled on Caddy. Easy to configure, available from the operating system package repository (so automatically managed and updated along other tools), plus already somewhat familiar to me from a different use-case, where it also works splendidly well.
To make usage a bit more convenient, I came up with the following helper script - it automatically determines the correct path no matter from where you run it, and instructs Caddy to serve files from that directory. Directory listings are also allowed, as they might be useful for debugging purposes.
#!/usr/bin/env bash
# Script should stop in case of any error encountered
set -e
set -o pipefail
# Copied from: https://mywiki.wooledge.org/BashFAQ/028, section "I need to access files bundled with my script"
# Pattern match the BASH_SOURCE variable, testing if a path has been defined
if [[ $BASH_SOURCE = */* ]]; then
scriptdir=${BASH_SOURCE%/*}/
else
echo "Bash script source path is unknown, assuming current directory as implicit starting point"
scriptdir=./
fi
# Compute the absolute directory
outputdir=$(realpath "$scriptdir")/output
echo "Serving files from directory: ${outputdir}"
# Run Caddy
caddy file-server --listen :3000 --root "${outputdir}" --browse
Enjoy!