Error: adapting config using caddyfile for webdav

1. The problem I’m having:

Cant make webdav to work.

2. Error messages and/or full log output:

Error: adapting config using caddyfile: parsing caddyfile tokens for 'route': unrecognized directive: webdav - are you sure your Caddyfile structure (nesting and braces) is correct?, at /etc/caddy/Caddyfile:18

3. Caddy version:

v2.9.1 h1:OEYiZ7DbCzAWVb6TNEkjRcSCRGHVoZsJinoDR/n9oaY=

4. How I installed and ran Caddy:

curl -s1sLf ‘https://dl.cloudsmith.io/public/caddy/stable/gpg.key’ | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg >> /dev/null 2>&1
curl -s1sLf ‘https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt’ | sudo tee /etc/apt/sources.list.d/caddy-stable.list >> /dev/null 2>&1
sudo apt update -y >> /dev/null 2>&1
sudo apt install caddy >> /dev/null 2>&1

a. System environment:

Linux Host 6.8.0-51-generic #52-Ubuntu SMP PREEMPT_DYNAMIC Thu Dec 5 13:09:44 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

b. Command:

systemctl start caddy and systemctl reload caddy

c. Service/unit/compose file:

[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target network-online.target
Requires=network-online.target

[Service]
Type=notify
User=caddy
Group=caddy
ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile --force
TimeoutStopSec=5s
LimitNOFILE=1048576
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target

d. My complete Caddy config:

{
	log {
		output file /var/log/caddy/caddy2.log
	}
	acme_ca https://acme-staging-v02.api.letsencrypt.org/directory
}

192.168.178.50 {
	    route {
		rewrite /dav /dav/
		basic_auth {
			dario REDACT
		}
		webdav {
			prefix /dav
			root /
 	}
  }
}

5. Links to relevant resources:

The webdav directive isn’t built-in. You need to build Caddy using xcaddy or use the download page.

1 Like

Thanks for help, make it working with
caddy add-package github.com/mholt/caddy-webdav

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.