I am trying to use Caddy2 as a reverse proxy for my UPS monitoring software, located at 10.0.1.4:3052. I also want to put it in a subdirectory under /ups because I will use Caddy to proxy other services. Currently when I access http://server/ups it first redirects to http://server/ups/local and then it redirects again to http://server/local/ which does not exist in Caddy and results in a blank page.
4. Error messages and/or full log output:
5. What I already tried:
route /ups* {
uri replace /ups/ /local/
reverse_proxy 10.0.1.4:3052
}
and
route /ups* {
uri replace /ups /local
reverse_proxy 10.0.1.4:3052
}
With these setup the basic http page got served. However, the files are still pointing to http://server/local/xxx.css which do not exist in Caddy. Checking the html source code shows that the files are pointing to the root of the web server.
This is the sort of situation where I’d recommend to avoid running the services in subpaths. Instead, I recommend using subdomains or different ports as entrypoints for each service.
Some services being proxied just don’t handle being proxied very well if they expect to be at a certain path. You would need to make sure to rewrite the URLs in the response body as well and that’s a slippery slope (and Caddy doesn’t natively support doing that right now).
It sounds like the backend app is redirecting because it doesn’t know it is being served under a subpath.
Yeah, so the app’s resources need to be in /local/ or whatever.
Frustratingly enough, most backend apps do not like being proxied. Some, like WordPress, you can configure for it, but others you can’t. You’ll have to configure the backend to allow being served in a subpath and/or to disable its redirects.