Are you referring to this part?
There’s one major difference, actually. A huge difference.
That example config isn’t stripping the URI prefix, whereas handle_path
does. That means for both upstreams, the request includes the /service-X/
prefix. In turn that means, by necessity, both upstreams must have been configured to expect that prefix and respond appropriately.
To be absolutely unambiguous here, with Matt’s example, you make a request to example.com/service-a/foo
and Caddy proxies that request to 192.168.0.2:8001/service-a/foo
. With YOUR config, you’re trying to make a request to 144.6.86.11/homarr/foo
and have Caddy proxy to homarr:7575/foo
. Did you note the missing /homarr
prefix? You’ve configured Caddy to hide that part from the upstream app, so it has no idea it’s there. The app only sees Caddy asking for /foo
.
As I’ve explained, the subfolder problem arises when you try to “trick” an upstream app to put it in a subfolder and that upstream app isn’t properly configured to do so. It’s a logic disagreement between the web server and the upstream app.
There is no inconsistency here, and our advice has never changed, only your understanding of it.
Caddy documentation even references the wiki post regarding the subfolder problem.
A full Caddyfile example, where
handle_path
andhandle
are mutually exclusive; but, be aware of the subfolder problem
I wish I could make a recommendation, but to the honest, absolute best of my knowledge, I am not aware of ANY software which can automatically resolve subfolder-related proxy/upstream conflicts.
The closest I can think of is that Apache httpd has a ProxyPassReverse
directive which fixes specifically Location headers somewhat automatically. Caddy has no specific syntactic sugar to make this happen, but it can be done with a header_down
rewrite.
ProxyPassReverse
very explicitly does not fix URLs in assets specified in HTML as it is not a HTML filter. That is what the custom module caddyserver/replace-response
is for in our case, and I’m not sure what the equivalent is in Apache but I’m quite HTML filtering is doable in their ecosystem - I just haven’t had to go there, myself.
Paths absolutely can work. I personally have quite a few apps in my mediaserver stack running in subfolders: Tautulli, Sonarr, Radarr, Lidarr, NZBHydra 2, NZBGet, and TubeSync.
I have a few others in that stack that I have not been able/felt it necessary to configure to play nicely in a subfolder, though: Maintainerr, Heimdall, Plex, CloudTorrent, and Overseerr.