I have a stock Unbuntu 16.06 droplet from DigitalOcean. I installed caddy with the tutorial caddy file and that worked. I then pointed a domain to the server and updated the caddy file. Now no matter what I do the caddy service will not start/restart. It constantly gets:
Started Caddy HTTP/2 web server.
Network Service is not active.
Dependency failed for Wait for Network to be Configured.
[Unit]
Description=Caddy HTTP/2 web server
Documentation=https://caddyserver.com/docs
After=network-online.target
Wants=network-online.target systemd-networkd-wait-online.service
; User and group the process will run as.
User=www-data
Group=www-data
; Letsencrypt-issued certificates will be written to this directory.
Environment=CADDYPATH=/etc/ssl/caddy
; Always set “-root” to something safe in case it gets forgotten in the Caddyfile.
ExecStart=/usr/local/bin/caddy -log stdout -agree=true -conf=/etc/caddy/Caddyfile -root=/var
ExecReload=/bin/kill -USR1 $MAINPID
; Limit the number of file descriptors; see man systemd.exec for more limit settings.
LimitNOFILE=1048576
; Unmodified caddy is not expected to use more than that.
LimitNPROC=64
; Use private /tmp and /var/tmp, which are discarded after caddy stops.
PrivateTmp=true
; Use a minimal /dev
PrivateDevices=true
; Hide /home, /root, and /run/user. Nobody will steal your SSH-keys.
ProtectHome=true
; Make /usr, /boot, /etc and possibly some more folders read-only.
ProtectSystem=full
; … except /etc/ssl/caddy, because we want Letsencrypt-certificates there.
; This merely retains r/w access rights, it does not add any new. Must still be writable o
ReadWriteDirectories=/etc/ssl/caddy
; The following additional security directives only work with systemd v229 or later.
; They further retrict privileges that can be gained by caddy. Uncomment if you like.
; Note that you may have to add capabilities required by any plugins in use.
;CapabilityBoundingSet=CAP_NET_BIND_SERVICE
;AmbientCapabilities=CAP_NET_BIND_SERVICE
;NoNewPrivileges=true
I’m not on DigitalOcean (although I love their guides), but does their stock Ubuntu install come with systemd-networkd or does it come with NetworkManager?
You might need to change the line to the following if it’s the latter:
For anyone else who might be looking, my understanding is that the usual procedure is to log to stdout, which should get picked up by systemd-journald. Other than that, ensuring the directory you want to write your logs to is group-writable and group-owned by www-data is a good way to go about it.