Reverse Proxy


How to implement a reverse proxy in Elixir (or Phoenix)?

In Go there is:


Is there any equivalent for Elixir?

Achievement: To proxy the current API.

No that I know of but this is close to a usecase I am considering as I build out my raxx framework. What you describe is easy if the path is sent as a list of segments. The psudo code I am aiming for would look something like this.

def handle_request(in_request = %{path: ["db" | rest]}, _) do
  out_request = %{in_request | path: rest, host: proxy_url}

p.s. I know that code that doesn’t yet exist might not be what you are looking for. However just in case its interesting here you go. I would also be interested in the case you do find a good way to do this anywhere else in the elixir ecosystem.

1 Like

Thanks! As an Elixir noob, currently I’m just wandering around to see what’s what! For example I’ve found :couchbeam which is a feature rich client for Erlang and is available as hex package too! I suspect this feature too might be somewhere in Erlang libs! After all Erlang is all about these kind of things. Maybe I should search more.

There is the terraform (github) package, it is designed specifically for proxy’ing an api endpoint while incrementally transforming it to elixir over time.

1 Like