How Caddy Serves a Static Site: The Request Flow
See how Caddy handles a request for a static site, from DNS resolution through container routing to file_server, and how TLS and redirects fit into the flow.
Fly.ioTutorial
A new community venture’s website is built with Hugo, served by Caddy, and deployed on Fly, with a custom makeroni.cc domain added after the initial deployment. The process initializes a Fly app on port 80, uses Hugo’s Quickstart and Ananke theme, and employs a multi-stage Docker build based on klakegg/hugo:0.74.0-onbuild, copying generated files into caddy:2.1.1. Caddy serves the static files with file_server while auto_https is disabled because Fly handles certificate management; separate rules serve makeroni.cc and redirect the old fly.dev hostname. DNS A and AAAA records connect the domain to Fly, and flyctl certs create requests a Let’s Encrypt certificate through DNS validation, leaving the site ready to serve securely after redeployment.
The author needed a website for a new community venture and chose Hugo and Caddy as compact, powerful Go-based tools, hosted on Fly. The deployment initially used a Fly-provided hostname before adding the custom makeroni.cc domain.
A multi-stage Docker build generates the static site with klakegg/hugo:0.74.0-onbuild, copies the output into caddy:2.1.1, and installs a Caddyfile. Fly handles TLS certificates, while DNS A and AAAA records, flyctl certs create, and Caddy host rules configure the custom domain and redirect the original hostname.
The Hugo build stage deposits generated files in /target, which the final Caddy image copies into /usr/share/caddy.
Caddy’s auto_https is disabled because Fly manages certificate handling; Caddy serves the site over HTTP behind Fly’s encrypted network.
The custom domain requires both an A record for Fly’s IPv4 address and an AAAA record for its IPv6 address before requesting a Let’s Encrypt certificate.
Summaries are generated from the original by a language model. Check the original before relying on it.
See the idea
See how Caddy handles a request for a static site, from DNS resolution through container routing to file_server, and how TLS and redirects fit into the flow.
Keep reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
One useful email. Unsubscribe anytime.