Everything was working properly until a few days ago when pages started to load without css and/or images. I found this issue and indeed adding a trailing slash to the url i typed in my browser seemed to solve the issue, although being a hacky solution. But then i noticed the websites couldn’t load many of their resources and were getting lots of 421 response codes because Caddy is redirecting, for example, example.com/transmission/web/rpc/foo/bar to example.com/rpc/foo/bar. I didn’t update anything in the last few days so i can’t explain why it worked before but it isn’t working now.
I thought it was a problem with proxies, so i fired up my old rTorrent + ruTorrent setup which i remember working perfectly fine, and again the website wasn’t even loading without adding a / to https://example.com/rutorrent. Added the slash and all the scripts weren’t working.
This is a doozy to wrap my head around, but I’ve used Transmission in the past (I’ve been using Cloud-Torrent nowadays).
I believe that Transmission is issuing relative links, and this is a problem with how those are universally handled. Because /transmission is seen as a file beneath /, and /transmission/ is seen as its own directory, we see the following behaviour for the example relative link, ./foo/bar:
URL
Result
example.com/transmission
example.com/foo/bar
example.com/transmission/
example.com/transmission/foo/bar
Now, while I’m having all sorts of trouble getting RPC working on a different subfolder, I did manage to get the page and all its assets loading properly with the following Caddyfile:
test.whitestrake.net/transmission {
redir {
if {uri} is /transmission
/ /transmission/
}
proxy / transmission:9091/transmission/web/
log stdout
errors stdout
gzip
}
https://test.whitestrake.net/transmission is a live website as of writing this post, so you can browse to it and check for yourself to see if it’s working as expected (as I mentioned, RPC is not working, so all you get is the actual page itself).
My final thoughts is that if I were you, I would try to put Transmission on its own subdomain and give it the root URI to save myself some headache.
P.S: Avoid using someone else’s registered domain name, such as redacted.com, when hiding your domain name in a publicly posted Caddyfile. The website http://example.com/ is reserved for this purpose, so use that instead. The entire .example TLD is also reserved in this way.
Thank you for your help. I’ve set up the Caddyfile following your suggestion and the site indeed loads correctly. Then it couldn’t reach the /rpc endpoint. I later thought i could use the subdomain suggestion and set up my Caddyfile like so:
I expect that transparent is not particularly necessary. All it does is set some headers - the upstream service needs to know to look for them, otherwise they won’t have any effect.
The web interface and the RPC interface are on different endpoints. You’re proxying all requests on the domain to /transmission/web/, including RPC calls, and the web interface doesn’t handle RPC, hence 405s (method not allowed) when the browser POSTs to it.