By the time the reverse_proxy line is done, the request processing is terminated as the response from upstream is returned. If you manually order anything after a terminating handler, it will never execute.
That said, the latest example won’t work for a request to /rp because the route is configured for /rp/* (note the trailing slash, which it will be picky about). That may be why it’s not working for you.
Still nothing, doesn’t work. And this line must be strip_prefix rp/
becouse like this
strip_prefix /rp
i have this error on run:
using adjacent Caddyfile
run: adapting config using caddyfile: parsing caddyfile tokens for 'route': Caddyfile:4 - Error during parsing: parsing caddyfile tokens for 'strip_prefix': Caddyfile:4 - Error during parsing: Wrong argument count or unexpected line ending after 'strip_prefix'
I can’t replicate this behaviour, although I did identify and solve another problem - Google would 404 me every time because the Host header sent upstream, by default, is the original client-requested localhost:2020. I had to override it to specify I wanted the upstream host.
Finally, with this last solution, redirect works as it should! Thank you very much! Another little question: is it possible to redirect the internal fileserver to something like localhost/fs or localhost/fileserve or whatever?
Excuse me again. I’m trying to reproduce the same configuration with caddy v1. I’ve tried with the option “without” but it doesn’t work. Could you post the same config for v1? Thank you again.
When you say “doesn’t work” - can you elaborate? What did you do, what result did you expect, and what result did you get instead? Be specific (quote any requests you made and exact errors returned).
@Whitestrake
Yep sorry, you are right: i was too much synthetic. Doesn’t work means that i can’t get rid of the /path during a reverse proxy configuration. Caddyfile V1 configuration is:
Caddy’s proxy does NOT issue a redirect. If you’re getting redirected (such as if you proxy to Google), it’s coming from upstream. The distinction is very important when you’re trying to achieve a specific result.