Caddy

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 the xcaddy repository.

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

Troubleshooting

Certificate error

If you are facing any issues related to SSL certificates (especially on non-public domains), it is probably because the running caddy instance does not have permission to add the certificate to the system's trust store. This seems to be the case when caddy.service is used to autostart caddy.

To fix this, run the following as root. You only have to run this once in a very long time (lifetime of the root certificate).

# XDG_DATA_HOME=/var/lib caddy trust
gollark: I mean, not exactly this, this is probably stupid and won't do much.
gollark: I do worry about the future of privacy given this sort of thing.
gollark: People would distrust most things if they mysteriously appeared out of nowhere/came from aliens.
gollark: * it is an eye, and also the eye of the person who claims to have it
gollark: As well as the various other problems, I don't understand how they can actually use this sort of thing to prevent Sybil attack issues without a central authority saying "yes, this is an eye".

See also

This article is issued from Archlinux. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.