Caddy

From ArchWiki
Jump to navigation Jump to search

Caddy is a HTTP/2 capable web server with automatic HTTPS.

Installation

Install the caddy package.

Plugins

If you need more than the base version of caddy, you can use xcaddy-binAUR to customize your caddy server build. This is useful if you need the additional plugins for DNS challenge etc. Alternatively, if a pre-built package, with the plugins you require, is already available you may choose to install those from AUR, for eg. caddy-cloudflareAUR

For a custom caddy server build you can use xcaddy to build caddy with the necessary plugin modules:

xcaddy build [<caddy_version>]
   [--output <file>]
   [--with <module[@version][=replacement]>...]

For more information, see xcaddy

Configuration

Caddy 2 supports various configuration formats, see config adapters (caddyfile, nginx, json, yaml, toml, among others).

Most commonly, Caddy is configured using a plain text file called Caddyfile. The Caddyfile starts with (an optional global options block and) an address of the site to be served, and is followed by a number of directives.

A simple Caddyfile hosting the site at localhost:2020:

{
  http_port 2020
}

localhost:2020
file_server

Usage

$ caddy help
$ caddy help run

Caddy can be run by any user from the page's directory, and the Caddyfile should be in the same directory:

$ caddy run

Alternatively you may specify a custom Caddyfile:

$ caddy run -config ../path/to/Caddyfile

See also