mirror of
https://github.com/caddyserver/caddy.git
synced 2024-11-26 02:09:47 +08:00
f1c1ea9905
Unlike network.target the network-online.target guarantees that the network devices are online. If you bind to 0.0.0.0, [::], [::1], and/or 127.0.0.1 only that is enough to proceed. But in case a particular IP is needed, like ${COREOS_PUBLIC_IPV4}, we require any IP assignments to have completed before Caddy's start. That is achieved by depending on systemd-networkd-wait-online.service (which is scheduled before network-online.target, then, automatically). |
||
---|---|---|
.. | ||
caddy@.service | ||
README.md |
systemd unit for caddy
Please do not hesitate to ask me if you've any questions.
Quickstart
- install the unit configuration file:
cp caddy@.service /etc/systemd/system
- reload the systemd daemon:
systemctl deamon-reload
- make sure to configure the service unit before starting caddy
- start caddy:
systemctl start caddy@someuser
- enable the service (automatically start on boot):
systemctl enable caddy@someuser
- the
.caddy
folder will be created inside the users home directory that runs caddy, i.e./home/someuser/.caddy
forsystemctl start caddy@someuser
Configuration
- do not edit the systemd unit directly, use systemd's builtin tools:
systemctl edit caddy@
to make user local modifications to the service unitsystemctl edit --full caddy@
to make system-wide modifications
- in most cases it's enough to adapt the
ExecStart
directive:systemctl edit caddy@
- systemd needs absolute paths, therefore make sure that the path to caddy is correct
- example:
[Service]
; reset the original setting
ExecStart=
ExecStart=/usr/bin/caddy -conf="/etc/caddy/myCaddy.conf" -agree -email="my@mail.address"
- to view your configuration use
systemctl cat caddy@
- double check the permissions of your web root path to make sure that caddy can access it as its run user and group
Tips
- use
log stdout
anderrors stderr
in your Caddyfile to make use ofjournalctl
journalctl
is systemd's log query tool- lets say you want all the log entries for caddy since the last boot beginning from the last entry:
journalctl --reverse --boot --unit caddy@someuser
- maybe you want to follow caddys log output:
journalctl -fu caddy@someuser
- to send a signal to a service units main PID, e.g. let caddy reload its config:
systemctl kill --signal=USR1 caddy@someuser