DEV Community

Athreya aka Maneshwar
Athreya aka Maneshwar

Posted on • Edited on

Serve Static Files with Caddy: Minimal Setup Guide

Hello, I'm Maneshwar. I'm building git-lrc, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. Star Us to help devs discover the project. Do give it a try and share your feedback for improving the product.

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 webserver 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
Enter fullscreen mode Exit fullscreen mode

2. Create Your Static Site Directory

mkdir -p /var/www/mysite
cd /var/www/mysite
echo "Hello from Caddy!" > index.html
Enter fullscreen mode Exit fullscreen mode

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
}
Enter fullscreen mode Exit fullscreen mode

Explanation:

  • :80 → Serve on HTTP port 80 (use yourdomain.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
Enter fullscreen mode Exit fullscreen mode

Or if running manually:

caddy run --config /etc/caddy/Caddyfile
Enter fullscreen mode Exit fullscreen mode

5. Test It

Visit:

http://localhost/
Enter fullscreen mode Exit fullscreen mode

You should see: Hello from Caddy!

Bonus: Enable HTTPS with a Domain

Update your Caddyfile:

yourdomain.com {
    root * /var/www/mysite
    file_server
}
Enter fullscreen mode Exit fullscreen mode

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
}
Enter fullscreen mode Exit fullscreen mode

Permissions

Make sure the Caddy user can read the static files:

sudo chown -R www-data:www-data /var/www/mysite
Enter fullscreen mode Exit fullscreen mode

Run Caddy Without Systemd (Manual Dev Mode)

caddy file-server --root /var/www/mysite --listen :8080
Enter fullscreen mode Exit fullscreen mode

That's it. Static hosting done right with minimal config.
Use it to serve SPAI’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.

Return it: FreeDevTools
⭐ Star it on GitHub: freedevtools

Let’s make it even better together.

git-lrc
*AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production.

git-lrc fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.*

Any feedback or contributors are welcome! It's online, source-available, and ready for anyone to use.

⭐ Star it on GitHub:

GitHub logo HexmosTech / git-lrc

Free, Unlimited AI Code Reviews That Run on Commit

git-lrc logo

git-lrc

Free, Unlimited AI Code Reviews That Run on Commit


git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

AI agents write code fast. They also silently remove logic, change behavior, and introduce bugs -- without telling you. You often find out in production.

git-lrc fixes this. It hooks into git commit and reviews every diff before it lands. 60-second setup. Completely free.

See It In Action

See git-lrc catch serious security issues such as leaked credentials, expensive cloud operations, and sensitive material in log statements

git-lrc-intro-60s.mp4

Why

  • 🤖 AI agents silently break things. Code removed. Logic changed. Edge cases gone. You won't notice until production.
  • 🔍 Catch it before it ships. AI-powered inline comments show you exactly what changed and what looks wrong.
  • 🔁 Build a habit, ship better code. Regular review → fewer bugs → more robust code → better results in your team.
  • 🔗 Why git? Git is universal. Every editor, every IDE, every AI…




Top comments (0)