# Reverse Proxy

**URL:** <https://forum.elixirforum.com/t/reverse-proxy/2695>\
**Category:** Discussions\
**Created:** [December 2, 2016, 8:26am UTC](https://forum.elixirforum.com/t/reverse-proxy/2695 "2016-12-02T08:26:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dc0d](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dc0d/32/27791_2.png) [@dc0d](https://forum.elixirforum.com/u/dc0d)\
**Post date:** [December 2, 2016, 8:26am UTC](https://forum.elixirforum.com/t/reverse-proxy/2695/1 "2016-12-02T08:26:14Z")

</div>

Hi,

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

In Go there is:

```go
	mux.Handle("/db*",
		http.StripPrefix("/db",
			httputil.NewSingleHostReverseProxy(proxyURL)))

```

Is there any equivalent for Elixir?

Achievement: To proxy the current API.

---

<div class="post-metadata">

**Author:** ![Crowdhailer](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/crowdhailer/32/2438_2.png) [@Crowdhailer](https://forum.elixirforum.com/u/Crowdhailer)\
**Post date:** [December 2, 2016, 9:49am UTC](https://forum.elixirforum.com/t/reverse-proxy/2695/2 "2016-12-02T09:49:53Z")

</div>

No that I know of but this is close to a usecase I am considering as I build out my [raxx](https://github.com/crowdhailer/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.

```elixir
def handle_request(in_request = %{path: ["db" | rest]}, _) do
  out_request = %{in_request | path: rest, host: proxy_url}
  Client.sent(out_request)
end

```

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.

---

<div class="post-metadata">

**Author:** ![dc0d](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dc0d/32/27791_2.png) [@dc0d](https://forum.elixirforum.com/u/dc0d)\
**Post date:** [December 2, 2016, 10:44am UTC](https://forum.elixirforum.com/t/reverse-proxy/2695/3 "2016-12-02T10:44:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![OvermindDL1](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/overminddl1/32/2677_2.png) [@OvermindDL1](https://forum.elixirforum.com/u/OvermindDL1)\
**Post date:** [December 2, 2016, 4:11pm UTC](https://forum.elixirforum.com/t/reverse-proxy/2695/4 "2016-12-02T16:11:38Z")

</div>

There is the [terraform](https://hex.pm/packages/terraform) ([github](https://github.com/poteto/terraform)) package, it is designed specifically for proxy’ing an api endpoint while incrementally transforming it to elixir over time.
