yes, that was the problem.
So I changed folder to home/pi/caddy so pi user can access it.
I put caddyfile also in that folder and changed caddy.service accordly.
here’s the full new version:
[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
[Service]
Restart=on-abnormal
; User and group the process will run as.
User=pi
Group=pi
; Letsencrypt-issued certificates will be written to this directory.
Environment=CADDYPATH=/home/pi/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=/home/pi/caddy/Caddyfile -root=/var/tmp
ExecReload=/bin/kill -USR1 $MAINPID
; Use graceful shutdown with a reasonable timeout
KillMode=mixed
KillSignal=SIGQUIT
TimeoutStopSec=5s
; 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 on the host!
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
[Install]
WantedBy=multi-user.target
so now something changed.
If i run sudo systemctl start caddy.service -l that’s the new error message:
● caddy.service - Caddy HTTP/2 web server
Loaded: loaded (/etc/systemd/system/caddy.service; enabled)
Active: failed (Result: exit-code) since sab 2017-08-26 18:19:16 CEST; 1min 4 2s ago
Docs: https://caddyserver.com/docs
Main PID: 602 (code=exited, status=1/FAILURE)
ago 26 18:19:14 jarvis systemd[1]: Started Caddy HTTP/2 web server.
ago 26 18:19:16 jarvis caddy[602]: Activating privacy features...
ago 26 18:19:16 jarvis caddy[602]: Your sites will be served over HTTPS automati cally using Let's Encrypt.
ago 26 18:19:16 jarvis caddy[602]: By continuing, you agree to the Let's Encrypt Subscriber Agreement at:
ago 26 18:19:16 jarvis caddy[602]: https://acme-v01.api.letsencrypt.org/terms
ago 26 18:19:16 jarvis caddy[602]: Please enter your email address so you can re cover your account if needed.
ago 26 18:19:16 jarvis caddy[602]: You can leave it blank, but you'll lose the a bility to recover your account.
ago 26 18:19:16 jarvis caddy[602]: Email address: 2017/08/26 18:19:16 get direct ory at 'https://acme-v01.api.letsencrypt.org/directory': failed to get json "htt ps://acme-v01.api.letsencrypt.org/directory": Get https://acme-v01.api.letsencry pt.org/directory: dial tcp: lookup acme-v01.api.letsencrypt.org on [::1]:53: rea d udp [::1]:37980->[::1]:53: read: connection refused
ago 26 18:19:16 jarvis systemd[1]: caddy.service: main process exited, code=exit ed, status=1/FAILURE
ago 26 18:19:16 jarvis systemd[1]: Unit caddy.service entered failed state.
It’s strange that i see connection refused. Ports 80 and 443 are still open on my router to the pi.
Any help?