reverse_proxy_plug icon indicating copy to clipboard operation
reverse_proxy_plug copied to clipboard

Add support for path params in the upstream path

Open col opened this issue 4 years ago • 1 comments
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")

col avatar May 02 '21 06:05 col

Does this also handle *_rest-style globs in the end of the template?

polvalente avatar May 18 '21 22:05 polvalente

Closing this as we're not using it anymore and it's not getting any traction here.

col avatar Sep 16 '22 01:09 col