When visiting the following directive I always go to the proxy. Even when visiting https://fileserver.mysite.com/complete. How do I get the precedence working? I thought it was “most specific wins” and /complete should be the most specific.
I can see why this is a little confusing; first, directives have a specific order, and then after that, the directive may choose how to order the rules based on path (some don’t and just use the order they’re given in, others like proxy do a length comparison).
As for directives, proxy actually has precedence over browse.
What you have going on is more like two separate sites, in a sense.
I’m gonna be honest, nginx’s config format is better structured for this type of thing. It allows you to do things that frankly the Caddyfile syntax doesn’t (or without a lot of repetition). But the Caddy way of thinking about sites is just a little different, and it ends up being simpler most of the time for most people once you get used to it.
One trick with this solution: the trailing slash on the request URL matters. I can request the browse directive with or without a trailing slash and it changes the generated pages.
good result - click around as expected and things are cool:
site url: https://fileserver.mysite.com/complete/
generated link: https://fileserver.mysite.com/complete/a-cool-folder/
bad result - links goes to a 404 error:
site url: https://candyhole.tureus.com/complete
generated link: https://fileserver.mysite.com/a-cool-folder/