I have to reverse proxy into https://example1.com and https://example2.com for different routes, I am using this configuration to hide the reverse proxy endpoints in my app. For me the /auth route works correctly, but the /history returns a 404 I did a curl request with the full correct url
Is there a way I can dump the full request (with the modified reverse proxied url) so I can see what is actually being sent to the reverse proxy
At first for me the /auth was also failing, then I finally figured out the Host header has to be modified because the origin is https
so I added
header_up Host {upstream_hostport}
which fixed it for me. but now the /history fails with 404, so I am looking for some debugging ideas on how I can dump out the request so I can see exactly which endpoint is called on the reverseproxy
You can turn on the debug global option to see more detailed logs, including information from the reverse_proxy module just before it proxies the request.
Also worth mentioning, you can simplify your config by using handle_path instead of route + uri strip_prefix, since it has built-in path prefix stripping logic.
In general though, most apps don’t behave well when the path prefix is stripped:
Those shortcuts are actually called placeholders in case you wondered
Here is the full list (hotlink to #placeholders)
But no, there is no placeholder for http.reverse_proxy.upstream.host.
However, those are defined in the following file and could easily be extended by filing a Pull Request. Maybe @matt could share his thoughts about the idea of adding some more placeholders
Actually, {http.reverse_proxy.upstream.host} does exist, it’s just that there’s no Caddyfile shortcut for that placeholder, but you can still use the long-form. See all the reverse_proxy placeholders in the JSON docs: