Skip to main content
xcaddy is the official build tool for Caddy that simplifies building custom binaries with plugins and proper version information.

What is xcaddy?

From README.md:145, xcaddy is our builder tool that automates the build process. It handles:
  • Creating proper project structure
  • Managing Go modules
  • Injecting version information
  • Adding custom plugins
  • Cross-compilation

Installation

Install xcaddy using Go:
Verify installation:
Ensure $GOPATH/bin is in your PATH to run xcaddy from anywhere.

Basic Usage

Build Standard Caddy

From README.md:148:
This creates a caddy binary in the current directory with:
  • Proper version information
  • All standard modules
  • Platform-specific optimizations

Build Specific Version

Or use a commit hash:
Or a branch:

Building with Plugins

Add a Plugin from GitHub

Add Multiple Plugins

Specify Plugin Version

Local Plugin Development

For local plugin development, use a local path:
The local path is relative to where you run xcaddy. Use absolute paths to avoid confusion.

Output Control

Specify Output Path

Cross-Platform Builds

What xcaddy Automates

From README.md:151, xcaddy performs these steps automatically:
1

Create project folder

2

Copy main.go

Copies Caddy’s main.go and adds plugin imports:
3

Initialize Go module

4

Pin Caddy version

5

Add plugin dependencies

6

Build with proper flags

Advanced Options

Replace Modules

Replace a dependency with a fork:

Build with Specific Go Version

Disable Module Optimization

By default, xcaddy trims unused dependencies:

Development Workflow

Quick Iteration

For rapid plugin development:

Using xcaddy run

Test without building:
This builds a temporary binary and runs it immediately.

Build Caching

xcaddy leverages Go’s build cache. Subsequent builds are faster:
Clear the cache if needed:

Environment Variables

Proxy Configuration

Private Repositories

Custom Build Flags

Common Plugin Examples

Nginx Config Adapter

Convert Nginx configs to Caddy:

CloudFlare DNS Provider

For DNS-01 ACME challenges:

Rate Limiting

Multiple Plugins Together

Verification

After building, verify your binary includes plugins:

Troubleshooting

Module Not Found

Ensure the plugin path is correct and accessible:

Version Conflicts

Specify exact versions:

Permission Denied

On Linux, set capabilities:

Build Fails with Local Plugin

Ensure your plugin has a go.mod file:

GOPROXY Timeout

Use direct mode:

Comparison with Manual Build

xcaddy is:
  • ✅ Faster and less error-prone
  • ✅ Handles version information correctly
  • ✅ Manages all dependencies automatically
  • ✅ Supports quick iteration with local plugins

Next Steps

Custom Builds

Create production-ready custom builds

Plugin Tutorial

Develop your own plugin

Building from Source

Manual build process details

Module Development

Deep dive into module creation