Caddy is essentially a configuration management system that can run various apps like an HTTP server, TLS certificate manager, PKI facilities, and more. It can be extended with plugins known as config modules.
</p>
<p>
Caddy sports a flexible and powerful HTTP reverse proxy, on-line configuration API, and a robust, production-ready static file server, and serves all sites over HTTPS by default with automagic TLS certificates.
</p>
<h3class="green">Overall program technical specifications</h3>
<divclass="feature-list">
<divclass="feature-row">
<h4>Language</h4>
<divclass="benefits">
The language choice is crucial for a web server. Most servers (NGINX, Apache, HAProxy, etc.) and their dependencies are written in C, which are vulnerable to catastrophic memory safety bugs like Heartbleed. Go programs like Caddy are impervious to a whole class of security vulnerabilities.
Caddy is statically compiled. Dynamically-linked applications can easily break in production and may be less secure as shared executable resources are loaded from various places around the system. Generally, Caddy binaries do not necessarily require external libraries — not even libc.
On consumer hardware, standard Caddy builds compile in just a few seconds. This is crucial for rapid iteration, plugin development, and low-cost deployments.
Caddy's regular expression language is <ahref="https://swtch.com/~rsc/regexp/regexp1.html">based on the Thompson NFA and has numerous performance improvements over PCRE</a> used by other web servers. It guarantees the runtime cost increases linearly instead of exponentially. This is ideal when evaluating untrusted input.
Go's runtime optimizes scheduled CPU time in smarter ways than the operating system can using lightweight user-space threads called goroutines. Caddy easily handles hundreds of thousands of requests per second.
Caddy can be extended by compile-time plugins, which compile as native code, in a way that cannot be broken during deployments or by system upgrades. With no IPC or RPC calls, Caddy extensions perform equally well with native code.
Top-level configuration structures are called app modules, or Caddy apps. They provide the bulk of Caddy's functionality. Anyone can write app modules, and Caddy comes with several standard apps built-in.
Assets and state, including certificates and OCSP staples, are stored in configurable storage backends. In fact, multiple instances of Caddy configured with the same storage are considered part of a cluster and can coordinate automatically.
Caddy's CLI is not only useful—it's <i>helpful</i>. While most server CLIs merely run the process and reload config, Caddy's CLI goes the extra lightyear to help make administering your modern web server a breeze.
</p>
<p>
Plugins can register their own subcommands to extend Caddy's CLI.
</p>
<divclass="feature-list">
<divclass="feature-row">
<h4>Command help</h4>
<divclass="benefits">
If you misspell a command or flag, miss an argument, or don't know the subcommand, help text is automatically printed. You can also access overall command help or subcommand help with <code>caddy help</code> or <code>-h</code>.
</div>
<divclass="detail">
Built-in, automatic (<code>man</code> pages can also be generated)
Several subcommands use administration API endpoints for use with the CLI to help you perform common tasks like loading config from files or stopping the server.
</div>
<ulclass="detail">
<li>Adapt config to JSON</li>
<li>Start the server, optionally with config</li>
<li>Gracefully reload configuration</li>
<li>Stop the server</li>
</ul>
</div>
<divclass="feature-row">
<h4>Binary utilities</h4>
<divclass="benefits">
Since custom builds of Caddy are so common, several commands exist to help you manage and get detailed information about your build.
</div>
<ulclass="detail">
<li>Detailed build metadata</li>
<li>List installed config modules</li>
<li>List dependencies</li>
<li>Add and remove plugin packages</li>
<li>Print the version</li>
<li>Upgrade the Caddy binary</li>
</ul>
</div>
<divclass="feature-row">
<h4>Configuration utilities</h4>
<divclass="benefits">
If you choose to use configuration files, Caddy's CLI helps you manage them.
</div>
<ulclass="detail">
<li>Format Caddyfile</li>
<li>Validate configuration</li>
<li>List dependencies</li>
<li>Add and remove plugin packages</li>
<li>Print the version</li>
</ul>
</div>
<divclass="feature-row">
<h4>Module utilities</h4>
<divclass="benefits">
Modules may register their own subcommands to provide common functionality that can be utilized without a config document.
</div>
<ulclass="detail">
<li>Static file server</li>
<li>HTTP reverse proxy</li>
<li>Static HTTP responses (templateable)</li>
<li>Storage import/export (backup/restore)</li>
<li>Hash password for use with HTTP basic auth</li>
<li>Export file browse template</li>
</ul>
</div>
<divclass="feature-row">
<h4>Integration utilities</h4>
<divclass="benefits">
Several subcommands can help you integrate Caddy into your shell environment.
</div>
<ulclass="detail">
<li>Generate shell completion script</li>
<li>Print the environment</li>
<li>Generate <code>man</code> pages</li>
<li>Install Caddy-managed root CA into trust stores</li>
<li>Remove Caddy-managed root CA from trust stores</li>
</ul>
</div>
<divclass="feature-row">
<h4>System signals</h4>
<divclass="benefits">
Caddy has support for common operating system signals/interrupts, with subtle differences in behavior for each one.
Whether Caddy exits successfully or with an error, the <ahref="/docs/command-line#exit-codes">exit code</a> can give a hint to your process supervisor or script how to handle that.
We've designed Caddy so that its configuration not only provides access to features, but <i>it IS a feature</i> in and of itself.
</p>
<p>
No more quibbling over which config file format is the best: use whatever you want! Caddy's <ahref="/docs/config-adapters">config adapters</a> allow you to use whatever config format you prefer.
</p>
<divclass="feature-list">
<divclass="feature-row">
<h4>Native config format</h4>
<divclass="benefits">
Caddy's native configuration format is ubiquitous: it has tooling in nearly every operating system, platform, programming language, and API ecosystem. Almost all other formats can be translated down into JSON, which balances human readability and programmability. You'll find it a powerful ally of your web server.
</div>
<divclass="detail">
JSON
</div>
</div>
<divclass="feature-row">
<h4>Config adapters</h4>
<divclass="benefits">
You can always write your config in another format and with config adapters, Caddy will implicitly translate it into JSON for you so you can work with what you like.
</div>
<ulclass="detail">
<li>Caddyfile</li>
<liclass="nonstandard">JSON 5</li>
<liclass="nonstandard">JSON-C</li>
<liclass="nonstandard">NGINX Conf</li>
<liclass="nonstandard">YAML</li>
<liclass="nonstandard">CUE</li>
<liclass="nonstandard">TOML</li>
<liclass="nonstandard">HCL</li>
<liclass="nonstandard">Dhall</li>
<liclass="nonstandard">MySQL</li>
</ul>
</div>
<divclass="feature-row">
<h4>Human-friendly config</h4>
<divclass="benefits">
The Caddyfile is most users' favorite way to write their web server config by hand because its syntax is forgiving while also being designed with a structure that makes it easy to read and write. It is translated to JSON automatically.
</div>
<divclass="detail">
Caddyfile
</div>
</div>
<divclass="feature-row">
<h4>Export</h4>
<divclass="benefits">
Caddy's administration API allows you to have runtime access to the current configuration in JSON format with a simple GET request.
</div>
</div>
<divclass="feature-row">
<h4>Config API</h4>
<divclass="benefits">
Caddy receives its configuration through an API endpoint, which can accept JSON or any other format it has a config adapter for.
</div>
</div>
<divclass="feature-row">
<h4>Config files</h4>
<divclass="benefits">
If you prefer normal commands to manage configuration, Caddy's CLI wraps the API endpoints for you.
Caddy's flagship feature is enabling HTTPS automatically and by default. You can control how it works or disable aspects: HTTP redirects, certificate management, certain hostnames, etc.
Each HTTP server can listen on one or more sockets and network interfaces. For ports, you can specify specific host interface or all interfaces with just a port. All varieties of unix sockets are also supported.
</div>
<ulclass="detail">
<li>TCP</li>
<li>UDP</li>
<li>Unix sockets</li>
</ul>
</div>
<divclass="feature-row">
<h4>Listener wrappers</h4>
<divclass="benefits">
Listeners can be wrapped by modules that operate at the connection-accept level.
</div>
<ulclass="detail">
<li>Redirect HTTP on HTTPS port</li>
<li>PROXY protocol</li>
<liclass="nonstandard">Tailscale</li>
</ul>
</div>
<divclass="feature-row">
<h4>Timeouts</h4>
<divclass="benefits">
Setting timeouts is an important defensive measure for production environments, but must be tuned carefully to accommodate legitimate slow clients with large downloads or uploads.
</div>
<ulclass="detail">
<li>Read timeout</li>
<li>Read HTTP header timeout</li>
<li>Write timeout</li>
<li>Idle timeout</li>
<li>TCP keepalive interval</li>
</ul>
</div>
<divclass="feature-row">
<h4>Full duplex communication</h4>
<divclass="benefits">
Concurrent reading and writing of HTTP/1 is not supported by all clients, but can be enabled for certain clients and applications that require it.
Caddy gives you full control over handling errors to give you clients the best/desired experience.
</div>
<divclass="detail">
Custom error routes
</div>
</div>
<divclass="feature-row">
<h4>TLS termination</h4>
<divclass="benefits">
Terminate TLS (formerly "SSL") with sensible defaults that you can customize to give you fine-grained control over TLS handshakes. You can assign policies to clients based on various factors such as ServerName (SNI) or remote IP.
</div>
<ulclass="detail">
<li>TLS 1.2</li>
<li>TLS 1.3</li>
<li>Client authentication (TLS mutual auth)</li>
<li>Client auth modes: request, require, verify if given, require and verify</li>
<li>Cipher suites</li>
<li>Curves</li>
<li>ALPN</li>
<li>Limit protocol versions</li>
<li>Default SNI</li>
<li>Fallback SNI</li>
</ul>
</div>
<divclass="feature-row">
<h4>Cross-site security</h4>
<divclass="benefits">
Caddy often serves multiple sites on the same socket, so Caddy automatically enables protections to keep your sites safe if any of them have TLS client auth enabled.
</div>
<divclass="detail">
Verification that TLS ServerName and HTTP Host header match
Caddy has the most flexible general-purpose reverse proxy in the world, featuring advanced request and response handling, dynamic routing, health checking, load balancing, circuit breaking, and more.
</p>
<p>
What makes Caddy's proxy unique is its design. Only the client-facing side of the proxy needs to be HTTP; the transport underlying the roundtrip with the backend can be fulfilled with any protocol!
</p>
<p>
Moreover, our proxy can be programmed with highly dynamic upstreams. That is, the available upstreams can change during in-flight requests! If no backends are available, Caddy can hold onto the request until one is.
</p>
<h3class="blue">High-level proxy features</h3>
<divclass="feature-list">
<divclass="feature-row">
<h4>Transports</h4>
<divclass="benefits">
Transports are how Caddy gets the response from the backend. Caddy's proxy can be a front for protocols other than HTTP by using alternate transport modules. This allows Caddy to generate HTTP responses from backends that don't even speak HTTP!
</div>
<ulclass="detail">
<li>HTTP</li>
<li>FastCGI</li>
<liclass="nonstandard">NTLM</li>
</ul>
</div>
<divclass="feature-row">
<h4>Load balancing</h4>
<divclass="benefits">
Selecting upstreams is a crucial function of any modern reverse proxy. Caddy has a variety of built-in load balancing policies to choose from to suit any production services. Some policies are extremely fast and lightweight; others provide upstream affinity based on properties of the client or request; others strive for even distribution by counting connections or using randomness and weights.
</div>
<ulclass="detail">
<li>Random</li>
<li>Random Choose-N</li>
<li>Least connections</li>
<li>Round robin</li>
<li>Weighted round robin</li>
<li>First available</li>
<li>Remote IP hash</li>
<li>Client IP hash</li>
<li>URI hash</li>
<li>Query hash</li>
<li>Header hash</li>
<li>Cookie hash</li>
</ul>
</div>
<divclass="feature-row">
<h4>Circuit breaking</h4>
<divclass="benefits">
A circuit breaker module can temporarily mark a backend as down before it actually goes down, to keep it up.
</div>
<divclass="detail nonstandard">
Latency-based
</div>
</div>
<divclass="feature-row">
<h4>Health checking</h4>
<divclass="benefits">
Health checks detect when upstreams are unavailable. Passive health checks infer status from actual requests. Active health checks work in the background, out-of-band of client requests.
</div>
<ulclass="detail">
<li>Active</li>
<li>Passive</li>
</ul>
</div>
<divclass="feature-row">
<h4>Observability</h4>
<divclass="benefits">
The admin API exposes an endpoint to retrieve the traffic count and health status of the proxy upstreams.
</div>
</div>
<divclass="feature-row">
<h4>Upstream sources</h4>
<divclass="benefits">
Caddy can get the list of upstreams in various ways. The most common is to write them into the configuration (static). Other ways are dynamic, by which a list of upstreams are returned for each request (these utilize configurable caching to enhance performance).
</div>
<ulclass="detail">
<li>Static</li>
<li>Dynamic: A records</li>
<li>Dynamic: SRV records</li>
<li>Dynamic: Multiple sources combined</li>
</ul>
</div>
<divclass="feature-row">
<h4>Streaming</h4>
<divclass="benefits">
Responses can be streamed directly to the client, or for better wire performance, buffered slightly and flushed periodically.
In order to use proxy-related headers like X-Forwarded-For, you can specify a list of IP ranges of proxies you trust. By default Caddy doesn't trust the clients.
The proxy can read the entire body before flushing it. This uses more memory but can be required by some backend applications or clients in some cases.
</div>
<ulclass="detail">
<li>Requests</li>
<li>Responses</li>
</ul>
</div>
<divclass="feature-row">
<h4>Request rewriting</h4>
<divclass="benefits">
Rewriting is a different concern from proxying and is normally handled separately, but sometimes you need to rewrite requests using information from the proxy like the chosen upstream. Caddy's proxy lets you do this.
</div>
</div>
<divclass="feature-row">
<h4>Response interception</h4>
<divclass="benefits">
By default, Caddy's proxy simply writes responses to the client. However, you can intercept the upstream's response and handle it in other ways. This includes matching only certain responses and invoking a custom handler chain you specify.
Active health checks assume a backend is down by default until that is confirmed otherwise by a health check.
</p>
<divclass="feature-list">
<divclass="feature-row">
<h4>HTTP request parameters</h4>
<divclass="benefits">
Active health checks are performed against an HTTP endpoint on the upstream. You can customize the parameters for these HTTP requests to work for you.
</div>
<ulclass="detail">
<li>Path & query string</li>
<li>Port</li>
<li>Headers</li>
</ul>
</div>
<divclass="feature-row">
<h4>Timing</h4>
<divclass="benefits">
You can customize the interval at which active health checks are performed.
</div>
</div>
<divclass="feature-row">
<h4>Success criteria</h4>
<divclass="benefits">
Each active health check can be customized with a set of criteria to determine healthy or unhealthy status.
</div>
<ulclass="detail">
<li>Response timeout</li>
<li>HTTP status code</li>
<li>Regular expression match on body</li>
</ul>
</div>
<divclass="feature-row">
<h4>Failure safety</h4>
<divclass="benefits">
Backends that are experiencing bugs and difficulties may sometimes respond with unexpectedly large response bodies. Caddy lets you limit this to preserve proxy resources.
</div>
<divclass="detail">
Limit response size
</div>
</div>
</div>
<h3class="purple">Passive health checks</h3>
<p>
Passive health checks assume a backend is up by default until failure criteria are met in the course of proxying requests.
</p>
<divclass="feature-list">
<divclass="feature-row">
<h4>Failure criteria</h4>
<divclass="benefits">
All passive health checks count connection failures. In addition, you can set more criteria needed to deem a backend as healthy during a request.
</div>
<ulclass="detail">
<li>Concurrent request limit exceeded</li>
<li>HTTP Status</li>
<li>Latency</li>
</ul>
</div>
<divclass="feature-row">
<h4>Failure memory</h4>
<divclass="benefits">
You can customize how long to remember failures and how many failures need to be in memory to consider a backend to be down.
Caddy's file server is the preferred way of serving static files for your website.
</p>
<p>
The way it works is simple: specify a root directory from which to serve the files, then request paths are automatically inferred as file paths relative to that root and the file is sent to the client.