Webdav & filebrowse default root and different paths for users

1. The problem I’m having:

I want to put some users in default root for both filebrowse and webdav and then some other users in a different hardcoded path which they cannot get out from with filebrowser and webdav as well all of them sitting behind basic_auth

root would be c:\stuff and for each users it would be something like

c:\stuff\tier1{http.auth.user.id}, I tried various way but failed with many possible scenarios including using {http.auth.user.id}(not sure if its supported for caddy windows?) gave 405 errors depending on if I was using / or \ in path and *.

I think the most supported way is to use “/” but in windows paths tend to be "", however that’s a bit of a side track and perhaps for another topic issue?

3. Caddy version:

v2.9.0-beta.2.0.20241004162330-88fd5f3491ab h1:teEhIzRZ2/VXBUG55bfZEauwYTOspd5k+k0raIYwqCE=

4. How I installed and ran Caddy:

Made version with xcaddy

xcaddy build master --with github.com/caddy-dns/cloudflare --with github.com/caddyserver/transform-encoder --with github.com/WeidiDeng/caddy-cloudflare-ip --with github.com/porech/caddy-maxmind-geolocation --with github.com/mholt/caddy-webdav

a. System environment:

Win11

b. Command:

caddy run

d. My complete Caddy config:

domain.com {
	@get method GET

	root * C:\stuff

	route {
		basic_auth {
			user password
		}
		file_server @get browse
		webdav
	}

}

5. Links to relevant resources:

You would need to set root after basic_auth, so you need to put root in your route to override the directive order (because root is ordered very early).

1 Like

I read the notes under the caddy-webdav git

{
	order webdav before file_server
}

Thanks…

But how would I integrated this with another path for some specific users when they login and they would get treated this path instead for both webdav & file_server browse

c:\stuff\tier1\{http.auth.user.id}

So all normal/default users ones would hit this for webdav & file_server browse

c:\stuff

You can use the vars matcher or map directive to test the value of {http.auth.user.id} and change root based on that.

Keep in mind that if c:\stuff\tier1\{http.auth.user.id} is inside of c:\stuff, then all your “default users” will also be able to see the contents of tier1. Wouldn’t it be better for it to be in separate subtrees?

1 Like

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