Which matcher does Caddy pick when there is a conflict?
In my understanding and experience reverse_proxy
takes precedence because directives have a default implicit order: https://caddyserver.com/docs/caddyfile/directives#directive-order .
To force a different order you have at least 3 options:
- use a route:
route /api/* {
file_server
reverse_proxy localhost:9000
}
- change the default order with the
order
global option - use
handle
withfile_server
beforereverse_proxy
From my understanding and experience, more specific is taken into consideration over more generic.
For instance in your case, anything matching /API/ should be forwarded to node, and anything else forwarded to the normal webserver.
At any rate, as long as /api/ isn't an actual folder on the website, requests hitting the website won't matter
Also see: https://caddyserver.com/docs/caddyfile/directives/root