Web / Caddy Server Interview questions
How do you build a custom Caddy binary with xcaddy?
xcaddy is a build tool that compiles a Caddy binary with extra modules baked in, since Caddy's plugins are added at compile time rather than loaded dynamically.
go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest xcaddy build \ --with github.com/caddy-dns/cloudflare \ --with github.com/mholt/caddy-ratelimit
Each --with flag names a Go module path for a plugin to include; xcaddy fetches it, generates a temporary main.go that imports every requested module alongside Caddy's core, and runs go build against that combination, producing a single static caddy binary with all requested modules registered.
For containerized deployments, the official caddy:builder Docker image runs the same process inside a multi-stage build, so a Dockerfile can produce a custom image without installing Go locally. Because everything is a compile-time decision, adding or removing a module always means rebuilding the binary rather than restarting with a new plugin file.
More Related questions...