Skip to main content
Custom Caddy builds allow you to include only the modules you need, add third-party plugins, and optimize for your deployment environment.

Why Custom Builds?

From README.md:175 and the architecture:
  • Extensibility: Add functionality without modifying Caddy’s source code
  • Optimization: Include only needed modules to reduce binary size
  • Integration: Bundle organization-specific plugins
  • Version control: Pin specific versions of Caddy and plugins
  • Performance: Compile for specific architectures
Caddy’s highly extensible modular architecture from README.md:92 makes custom builds practical and maintainable.

Build Methods Overview

xcaddy (Recommended)

Fast, automated builds with plugin management

Manual Process

Full control over build configuration
From README.md:145, xcaddy is the official build tool.

Install xcaddy

Basic Custom Build

See the xcaddy documentation for complete details.

Manual Custom Build

For full control, follow these steps from README.md:151 and cmd/caddy/main.go:15:
1

Create build directory

2

Create main.go

Based on cmd/caddy/main.go:
The blank import _ triggers the plugin’s init() function which registers the module.
3

Initialize Go module

4

Pin Caddy version

5

Add plugin dependencies

6

Tidy dependencies

7

Build

From README.md:159:

Standard Modules

From modules/standard/imports.go:1, standard modules include:
Do not remove modules/standard unless you know exactly which modules you need. Many features depend on these.

Minimal Build

For embedded systems or containers, create a minimal build:
Build with maximum optimization:

DNS Provider Build

For automated TLS with DNS-01 challenges:

Enhanced Security Build

Monitoring Build

The tracing module is from modules/caddyhttp/tracing/module.go:15.

Config Adapter Build

Version Information

From caddy.go:940, inject custom version info:
The version appears in:

Cross-Platform Builds

Linux AMD64

Windows AMD64

macOS ARM64 (Apple Silicon)

Linux ARM64 (ARM servers)

Linux ARM (Raspberry Pi)

Build Optimization

Reduce Binary Size

Flags:
  • -tags: Exclude optional dependencies
  • -ldflags="-s -w": Strip debug info
  • -trimpath: Remove file paths
Further compress with UPX:

Static Binary

From README.md:93, build with no external dependencies:

Faster Builds

Enable parallel compilation:
Use build cache:

Dockerfile Build

Multi-stage build for minimal image:

Automated Build Pipeline

GitHub Actions Example

Verification

After building, verify your custom binary:

Distribution

Create Release Archive

Generate Checksums

Sign Release

Maintenance

Update Caddy Version

Update Plugins

Security Updates

Best Practices

Version everything: Pin specific versions of Caddy and all plugins in production.
Test thoroughly: Run your test suite against custom builds before deploying.
Document plugins: Maintain a list of included plugins and their versions.
Automate builds: Use CI/CD to build consistently across environments.
Keep builds minimal: Only include plugins you actually use.

Next Steps

xcaddy Tool

Master xcaddy for easier custom builds

Module Development

Create your own custom modules

Testing Guide

Test your custom builds thoroughly

Contributing

Share your build configurations