caddy-retired/systemd
David Kebler e24be310ae reworked caddy script - removed cmdline support for netbind
systemd service install now uses sed to insert the repo directory into the call service script before deploying.
renamed install script to fetch as to avoid confusion as it fetches the basic binary.
2020-11-27 15:52:32 -08:00
..
README.md add aws credentials secret 2020-05-17 19:33:35 -07:00
caddy-api.service first commit 2020-05-12 20:07:05 -07:00
caddy-service.md new install script for github releases 2020-10-26 10:11:41 -07:00
caddy@.service reworked caddy script - removed cmdline support for netbind 2020-11-27 15:52:32 -08:00
install reworked caddy script - removed cmdline support for netbind 2020-11-27 15:52:32 -08:00
log added linux-amd64 2020-11-27 08:21:18 -08:00
persist added linux-amd64 2020-11-27 08:21:18 -08:00
start added linux-amd64 2020-11-27 08:21:18 -08:00
stop added linux-amd64 2020-11-27 08:21:18 -08:00

README.md

Official service files for systemd

This folder contains the officially-maintained systemd files that should be used as a basis for your own deployments.

⚠️ Always review your service file before using it! Change anything that you need to customize.

Instructions

See our website for installation instructions.

Prerequisites

Running Caddy as a systemd service requires the following:

Group named caddy:

$ groupadd --system caddy

User named caddy with a writeable home folder:

$ useradd --system \
    --gid caddy \
    --create-home \
    --home-dir /var/lib/caddy \
    --shell /usr/sbin/nologin \
    --comment "Caddy web server" \
    caddy

Choosing a service file

  • caddy.service - Use this one if you configure Caddy with a file (for example, the Caddyfile, or a .json file).
  • caddy-api.service - Use this one if you configure Caddy solely through its API.

The two files are identical except for the ExecStart and ExecReload commands.

Important

Caddy receives all configuration through its admin API, even when the command line interface (CLI) is used, which simply wraps up the API calls for you.

Most users will use either config files and the CLI mutually exclusively with the API because it is simpler to have only one source of truth. However, you may wish to provide Caddy an initial "bootstrapping" configuration with a config file, and use the API thereafter.

⚠️ If you provide an initial config file with the --config flag and then update the config using the API, you risk losing your changes if the service is restarted unless you have the --resume flag in your ExecStart command.

Without the --resume flag, the --config flag will overwrite any last-known configuration.

However, it is totally safe and normal to use both the --config and --resume options together if you need to use both a config file and the API. Just be aware that if you update your config file and want to apply those changes, stopping and starting the server is the wrong way to do this. Restarting the service is orthogonal to config changes; this is a unique safety feature that guarantees durability and prevents data loss. If the config file has the latest changes, you should use the reload command instead.