LinuxCommandLibrary

caddy

Serve websites easily and automatically

TLDR

Start Caddy in the foreground

$ caddy run
copy

Start Caddy with the specified Caddyfile
$ caddy run --config [path/to/Caddyfile]
copy

Start Caddy in the background
$ caddy start
copy

Stop a background Caddy process
$ caddy stop
copy

Run a simple file server on the specified port with a browsable interface
$ caddy file-server --listen :[8000] --browse
copy

Run a reverse proxy server
$ caddy reverse-proxy --from :[80] --to localhost:[8000]
copy

SYNOPSIS

caddy [command] [flags]

PARAMETERS

adapt
    Adapts a configuration from one format to another.

environ
    Prints the environment.

file-server
    Serves files from a directory.

fmt
    Formats a Caddyfile.

hash-password
    Generates a password hash.

help
    Shows help for a command.

list-modules
    Lists available Caddy modules.

reverse-proxy
    Proxies requests to upstream servers.

run
    Starts the Caddy server in the foreground.

start
    Starts the Caddy server in the background.

stop
    Stops the Caddy server.

trust
    Trusts a certificate authority.

untrust
    Untrusts a certificate authority.

validate
    Validates a Caddy configuration.

version
    Shows the Caddy version.

flags
    Flags modify the behaviour of the selected command, --config, --adapter are common flags

DESCRIPTION

Caddy is a powerful, adaptable, and easy-to-use open-source web server. It automates HTTPS configuration (including certificate management) by default, making secure web development accessible to everyone. Caddy's automatic HTTPS is powered by Let's Encrypt, ZeroSSL, or any ACME CA. It also supports custom certificate authorities. Caddy can serve static files, reverse proxy, load balance, and more, using a simple configuration file (Caddyfile) or its JSON API. It's designed for ease of use and high performance, making it suitable for a wide range of web applications, from simple static sites to complex web applications and APIs. Caddy prioritizes security and modern web standards.
Caddy also has extensive support for multiple protocols like HTTP/1.1, HTTP/2, and HTTP/3

CAVEATS

Caddy's automatic HTTPS relies on having a publicly accessible domain name. Port 80 and 443 needs to be open on the server's firewall in order to get certificates from ACME servers like Let's Encrypt.

<B>CONFIGURATION</B>

Caddy can be configured via a Caddyfile, which is a simple text-based configuration file, or via a JSON API. The Caddyfile is generally preferred for its readability and ease of use.

<B>MODULES</B>

Caddy's modular architecture allows it to be extended with various modules that add functionality such as support for different protocols, storage backends, and more.

HISTORY

Caddy was first released in 2015 by Matthew Holt. It was designed with a focus on automation, security, and ease of use. Caddy v2, a complete rewrite, was released in 2020 and introduced a modular architecture and a JSON API, making it even more powerful and extensible. Caddy has gained popularity due to its automatic HTTPS configuration and simple Caddyfile configuration.

SEE ALSO

nginx(8), apache2(8)

Copied to clipboard