Dynamic reverse proxy with strip_prefix

Sounds like what you want is a forward proxy, not a reverse proxy. What you’re trying is really weird for reverse_proxy.

There is a forwardproxy Caddy plugin, but support for v2 isn’t complete, I think. (/cc @matt Support Caddy 2 by mholt · Pull Request #74 · caddyserver/forwardproxy · GitHub)

That said, you could probably use a path_regexp matcher to extract the part of the URL you want before stripping the prefix, then using the regexp capture group, which’ll be preserved after stripping.