I can only give you what works for me.
nas.mydomain.duckdns.org {
log {
output file /var/log/caddy/nas.log
format console
}
root * /srv/dev-disk-by-label-HomeDrive/
@noAccess {
not path "*/My Pictures/*"
not path */RESTRICTED/*
not path "/config files/Caddy2/caddyfilenas.txt"
}
file_server @noAccess browse {
hide RESRICTED "My Pictures"
}
encode gzip
basicauth {
username (hashbrown64)
}
}
Be sure if you folders/filenames have a space in them that you use quotes. As you see in mine I had to completely wrap the 1st and 3rd ‘not path’ in quotes because of white space contained in them. The 2nd one didn’t need quotes.
Also I chose to not only deny access but hide two of the folders also. This does however hide them from me also when accessing through a browser. I can still get them if I go directly to the hard drive from my windows PC.
I’m still trying to figure out exactly how the hide module works in regards to hiding only one instance of a specified file/folder name. See post here Help hiding only one named folder - #5 by jfirestorm44
Let me know if that works for you.
EDIT: Be sure to clear you browser cache after reloading your new config. I had an issue where the caddyfilenas.txt kept allowing me to see if even though I shouldn’t have been able to. Once I cleared the cookies/cache I could no longer access it.