Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission/Path issues with webdav-module using systemd service #21

Open
firestorm99 opened this issue Feb 18, 2021 · 0 comments
Open

Comments

@firestorm99
Copy link

firestorm99 commented Feb 18, 2021

Hi,

first of all, thanks a lot for the webdav-module. :) I had some trouble getting things to run smoothly and thought it might be a good idea to share the solutions.

Background: I wanted to use webdav to store and share notes with my wife. I encountered the following problems while installing, which my have occurred to others.

My system: Debian Buster running caddy v2.3.0 h1 with a systemd service (I swapped the executable in /usr/bin/ with the one including the webdav module).

Things that were not clear for me from the webdav module readme:

1. get the root right:
The readme example does not work with the systemd service.
Read-me example:

webdav /some/path/match/* {
	root /path
	prefix /some/path/match
}

I had to change it to:

        webdav /webdav/* {
           root /usr/share/caddy/webdav
           prefix /webdav
        }

In my case the webserver root in the caddyfile is root * /usr/share/caddy, which means that the path structure of the example is different.

2. Fix permissions while using a systemd service:
Although caddy had all the necessary permissions to the webdav directory it still complained about permissions:
Feb 18 23:18:48 vps caddy[12627]: {"level":"error","ts":1613686728.1413567,"logger":"http.handlers.webdav","msg":"internal handler error","error":"open /usr/share/caddy/webdav/silentnotes_repository.silentnotes: read-only file system","request":{"remote_addr":"x.x.x.x:123","proto":"HTTP/1.1","method":"PUT","host":"x.x.com","uri":"/webdav/silentnotes_repository.silentnotes","headers":{"Content-Length":["832"],"Authorization":["Basic c3xlZmAuOlYySXIxZg=="],"Accept-Encoding":["gzip, deflate"]},"tls":{"resumed":false,"version":771,"cipher_suite":49200,"proto":"","proto_mutual":true,"server_name":"x.x.com"}}}

Fix: Follow https://caddy.community/t/problem-with-filemanager-plugin-and-systemd/3900/3 and add a ReadWriteDirectories directive to the systemd file, as ProtectSystem=full prevents this.
In my case this results in:

User=caddy
Group=caddy
ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE
ReadWriteDirectories=/usr/share/caddy/webdav

If you find these notes useful, please add them to the module read-me page. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant