I’ve tried to set up a filemanager site with caddy plugin http.filemanager.
My caddy version is Caddy 0.11.0 (non-commercial use only)
I have set database path in the Caddyfile, and trying to manage the daemon with systemctl.
systemctl start caddy
systemctl status caddy
and it shows me with failure
● caddy.service - Caddy HTTP/2 web server
Loaded: loaded (/etc/systemd/system/caddy.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2018-05-21 10:14:00 CST; 35min ago
Docs: https://caddyserver.com/docs
Process: 31989 ExecStart=/usr/local/bin/caddy -conf /etc/caddy/Caddyfile -root /tmp (code=exited, status=1/FAILURE)
Main PID: 31989 (code=exited, status=1/FAILURE)
5月 21 10:14:00 Host systemd[1]: Started Caddy HTTP/2 web server.
5月 21 10:14:00 Host caddy[31989]: Activating privacy features... done.
5月 21 10:14:00 Host caddy[31989]: 2018/05/21 10:14:00 open /etc/caddy/filemanager.db: read-only file system
5月 21 10:14:00 Host systemd[1]: caddy.service: Main process exited, code=exited, status=1/FAILURE
5月 21 10:14:00 Host systemd[1]: caddy.service: Failed with result 'exit-code'.
I checked the privilege of the database file:
$ ls -la /etc/caddy/
总用量 60
drwxr-xr-x 2 www-data www-data 4096 5月 20 21:03 .
drwxr-xr-x 114 root root 12288 5月 19 17:53 ..
-rw-r--r-- 1 www-data www-data 999 5月 20 21:03 Caddyfile
-rw-r--r-- 1 www-data www-data 65536 5月 20 21:19 filemanager.db
here is my Caddyfile:
$ cat /etc/caddy/Caddyfile
file.mydomain:443 {
log /var/log/caddy/fileserver.log {
rotate_size 5
rotate_age 20
rotate_keep 20
rotate_compress
}
tls myemail@gmail.com
filemanager / /mnt/CloudDisk {
url /
database /etc/caddy/filemanager.db
allow_new false
allow_publish true
allow_edit false
allow_commands false
locale zh_cn
}
}
the systemd file:
$ cat /etc/systemd/system/caddy.service | sed -e '/^;/d'
[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=www-data
Group=www-data
Environment=CADDYPATH=/etc/ssl/caddy
ExecStart=/usr/local/bin/caddy -conf /etc/caddy/Caddyfile -root /tmp
ExecReload=/bin/kill -USR1 $MAINPID
KillMode=mixed
KillSignal=SIGQUIT
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateTmp=true
PrivateDevices=true
ProtectHome=true
ProtectSystem=full
ReadWriteDirectories=/etc/ssl/caddy
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_BIND_SERVICE
NoNewPrivileges=true
[Install]
WantedBy=multi-user.target
I also tried to run caddy with user www-data in command line without systemd, and it works:
$ sudo -u www-data caddy -conf /etc/caddy/Caddyfile -root /tmp/
Activating privacy features... done.
https://file.mydomain
http://file.mydomain
WARNING: File descriptor limit 1024 is too low for production servers. At least 8192 is recommended. Fix with "ulimit -n 8192".
So it really confuse me why it can’t work with systemd…