Hello, I'm Maneshwar. I'm working on FreeDevTools online currently building **one place for all dev tools, cheat codes, and TLDRs* — a free, open-source hub where developers can quickly find and use tools without any hassle of searching all over the internet.
Caddy is a lightweight, modern web server wi
th automatic HTTPS, easy config, and a powerful plugin ecosystem. Here's how to quickly serve static files with it.
1. Install Caddy
On Debian/Ubuntu:
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy
2. Create Your Static Site Directory
mkdir -p /var/www/mysite
cd /var/www/mysite
echo "Hello from Caddy!" > index.html
You can place any static files here (HTML, CSS, JS, images, etc.).
3. Write the Caddyfile
Create a file named Caddyfile
(default location: /etc/caddy/Caddyfile
)
:80 {
root * /var/www/mysite
file_server
}
Explanation:
-
:80
→ Serve on HTTP port 80 (useyourdomain.com
for HTTPS). -
root * /var/www/mysite
→ Set the root directory. -
file_server
→ Enable static file serving.
4. Reload Caddy
After saving the Caddyfile:
sudo systemctl reload caddy
Or if running manually:
caddy run --config /etc/caddy/Caddyfile
5. Test It
Visit:
http://localhost/
You should see: Hello from Caddy!
Bonus: Enable HTTPS with a Domain
Update your Caddyfile:
yourdomain.com {
root * /var/www/mysite
file_server
}
Caddy will automatically fetch and renew the SSL cert via Let's Encrypt.
Make sure port 80 and 443 are open, and DNS is correctly set.
Optional: Directory Browsing
:80 {
root * /var/www/mysite
file_server browse
}
Permissions
Make sure the Caddy user can read the static files:
sudo chown -R www-data:www-data /var/www/mysite
Run Caddy Without Systemd (Manual Dev Mode)
caddy file-server --root /var/www/mysite --listen :8080
That's it. Static hosting done right with minimal config.
Use it to serve SPAs, HTML dumps, or just quick previews.
I’ve been building FreeDevTools.
A collection of UI/UX-focused tools crafted to simplify workflows, save time, and reduce friction in searching tools/materials.
Any feedback or contributors are welcome!
It’s online, open-source, and ready for anyone to use.
👉 Check it out: FreeDevTools
⭐ Star it on GitHub: freedevtools
Let’s make it even better together.
Top comments (0)