I’m having some trouble setting up a fairly simple reverse proxy. The background is that I have my site hosted in GitHub pages (here) and I’d like to reverse proxy to that from my main domain. The docs used to be hosted somewhere else which allowed trailing slashes (e.g. https://placeholder-software.co.uk/dissonance/docs/Basics/Getting-Started/ should show the same contents as https://placeholder-software.co.uk/dissonance/docs/Basics/Getting-Started.html). I’m struggling to set this up.
What exactly is the problem? Did you try that? What doesn’t work, specifically? What do you see in your logs? What does it look like when you make a request with curl -v?
Please don’t remove parts of the help topic template. All the parts are necessary for us to properly understand the problem and to have an idea how to help you.
Thanks for the fast response! Sorry I wasn’t clear about the problem.
What exactly is the problem?
What doesn’t work, specifically?
Fetching the site with a trailing slash delivers a broken version of the content, i’m not sure why. I suspect I’m simply not understanding something fundamental about how caddy does reverse_proxy.
If you scroll past the hilariously large icons the correct content is there.
What does it look like when you make a request with curl -v?
Here is the complete response from curl -v https://placeholder-software.co.uk/dissonance/docs/Basics/Getting-Started/
What do you see in your logs?
The journalctl log for caddy has some log spam about https issuance errors (note this is for a different domain, not the one we’re talking about). e.g.
Sep 05 02:24:21 placeholder-software caddy[865]: {“level”:“error”,“ts”:1662341061.0472126,“logger”:“tls.issuance.acme”,“msg”:“looking up info for HTTP challenge”,“host”:“placeholder.software”,“error”:“no information found to solve challenge for identifier: placeholder.software”}
Sep 05 02:24:21 placeholder-software caddy[865]: {“level”:“error”,“ts”:1662341061.0484319,“logger”:“tls.issuance.acme”,“msg”:“looking up info for HTTP challenge”,“host”:“placeholder.software”,“error”:“no information found to solve challenge for identifier: placeholder.software”}
On closer inspection I think the issue is to do with the relative paths for css files and the reverse proxy is working fine. I was fixating on looking for the problem in the wrong place!
For example the html includes this: <link rel="stylesheet" href="../assets/stylesheets/main.69437709.min.css"> which explains why the content is there, but the styling is missing.
Given that, I think the easiest way to fix this will be to redirect if it has a trailing slash.
Ah okay, so it seems like the problem is with loading CSS/JS assets for your site from that URL, the relative paths for those end up broken.
I think you probably want to do a redirect instead a rewrite to fix this, because the problem is with the browser not knowing the correct relative path for the assets because it uses ../ to go up a path segment, but the trailing / means there’s one too many path segments to get to the right place.
This’ll match the path with a regexp, capturing the whole URI except the slash, then redirect if it matches to a URL with the captured part. (Need to re-add /dissonance/docs because handle_path will have stripped it away).