reverse_proxy_plug
reverse_proxy_plug copied to clipboard
Add support for path params in the upstream path
trafficstars
PlugRouter.forward supports path params in the incoming path (see: https://hexdocs.pm/plug/Plug.Router.html#forward/2) but ReverseProxyPlug does not currently support using these in the upsteam path.
This is a fairly simple change but it allows for some simple URL rewriting for specific paths.
Example
# Forward this specific path to a new service that uses a new path structure
forward("/foo/users/:id/profile", to: ReverseProxyPlug, upstream: "new-foo.com/user-profile/:id")
# Forward all other paths to the original service
forward("/foo", to: ReverseProxyPlug, upstream: "foo.com")
Does this also handle *_rest-style globs in the end of the template?
Closing this as we're not using it anymore and it's not getting any traction here.