# How to create an HTTP Proxy?

**URL:** <https://forum.elixirforum.com/t/how-to-create-an-http-proxy/60847>\
**Category:** Questions\
**Tags:** proxy, http-requests, web\
**Created:** [January 8, 2024, 9:19pm UTC](https://forum.elixirforum.com/t/how-to-create-an-http-proxy/60847 "2024-01-08T21:19:00Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![chgeuer](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/chgeuer/32/10510_2.png) [@chgeuer](https://forum.elixirforum.com/u/chgeuer)\
**Post date:** [January 8, 2024, 9:19pm UTC](https://forum.elixirforum.com/t/how-to-create-an-http-proxy/60847/1 "2024-01-08T21:19:00Z")

</div>

Which library / approach would be advisable for building an MITM-style HTTP(s) Proxy, i.e. for intercepting outgoing web traffic? Effectively inspect (and do side effects) based on outgoing traffic.

I found [GitHub - houli/http-proxy: A HTTP(S) Proxy written in Elixir · GitHub](https://github.com/houli/http-proxy) (9 years old, work in progress) and [GitHub - KazuCocoa/http\_proxy: http proxy with Elixir. wait request with multi port and forward to each URIs · GitHub](https://github.com/KazuCocoa/http_proxy), but there’s no real getting-started sample. Given that a proxy isn’t just a regular web server, I’m not sure this thing can easily be plugged into a web server like Cowboy/Bandit/Phoenix…

Thanks, Christian

---

<div class="post-metadata">

**Author:** ![D4no0](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/d4no0/32/33624_2.png) [@D4no0](https://forum.elixirforum.com/u/D4no0)\
**Post date:** [January 8, 2024, 9:43pm UTC](https://forum.elixirforum.com/t/how-to-create-an-http-proxy/60847/2 "2024-01-08T21:43:04Z")

</div>

> [@chgeuer](#):
>
> Given that a proxy isn’t just a regular web server, I’m not sure this thing can easily be plugged into a web server like Cowboy/Bandit/Phoenix…

How so? The requirements may widely wary, however I can see how you could have a combination of phoenix and a http client.

---

<div class="post-metadata">

**Author:** ![sorax](https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@sorax](https://forum.elixirforum.com/u/sorax)\
**Post date:** [January 8, 2024, 9:48pm UTC](https://forum.elixirforum.com/t/how-to-create-an-http-proxy/60847/3 "2024-01-08T21:48:59Z")

</div>

do you know [https://github.com/tallarium/reverse\_proxy\_plug](https://github.com/tallarium/reverse_proxy_plug)?  
we use it for “shielding” an old website and injecting css into the page

kind regards, robert

---

<div class="post-metadata">

**Author:** ![arcanemachine](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/arcanemachine/32/29109_2.png) [@arcanemachine](https://forum.elixirforum.com/u/arcanemachine)\
**Post date:** [January 8, 2024, 11:09pm UTC](https://forum.elixirforum.com/t/how-to-create-an-http-proxy/60847/4 "2024-01-08T23:09:09Z")

</div>

Not sure if this is helpful, but I use this service a lot for finding Elixir packages:

> **[Search: proxy](https://elixir-toolbox.dev/packages/search?query=proxy)**
>
> Search results for "proxy" across Elixir packages.

---

<div class="post-metadata">

**Author:** ![chgeuer](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/chgeuer/32/10510_2.png) [@chgeuer](https://forum.elixirforum.com/u/chgeuer)\
**Post date:** [January 9, 2024, 1:56pm UTC](https://forum.elixirforum.com/t/how-to-create-an-http-proxy/60847/5 "2024-01-09T13:56:55Z")

</div>

Thanks @sorax . I had a look at that, but it seems targeted as “reverse proxy”, like NGINX, right? That looked like a component I can put in front of my web server application, and route incoming requests different ways, like an API Gateway.

I’m looking for a component used by a web browser, before going out to the Internet. Is reverse\_proxy\_plug usable for that, too? The proxy protocol looks slightly different than HTTP

---

<div class="post-metadata">

**Author:** ![chgeuer](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/chgeuer/32/10510_2.png) [@chgeuer](https://forum.elixirforum.com/u/chgeuer)\
**Post date:** [January 9, 2024, 5:26pm UTC](https://forum.elixirforum.com/t/how-to-create-an-http-proxy/60847/6 "2024-01-09T17:26:40Z")

</div>

Fully agree that I want the proxy server to run on a solid foundation (like Phoenix). The thing that’s unclear is how to host a component that talks the proxy protocol to the client, instead of plain HTTP.

---

<div class="post-metadata">

**Author:** ![chgeuer](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/chgeuer/32/10510_2.png) [@chgeuer](https://forum.elixirforum.com/u/chgeuer)\
**Post date:** [January 9, 2024, 5:31pm UTC](https://forum.elixirforum.com/t/how-to-create-an-http-proxy/60847/7 "2024-01-09T17:31:04Z")

</div>

Thanks for the link, wasn’t aware of the search capabilities of elixir-toolbox.dev… However, as far as I can see, all these are either proxies for special protocols (SIP, Kafka, Telegram MProto) or are ‘reverse proxies’ (like nginx).

---

<div class="post-metadata">

**Author:** ![foucist](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/foucist/32/31003_2.png) [@foucist](https://forum.elixirforum.com/u/foucist)\
**Post date:** [July 5, 2024, 5:38pm UTC](https://forum.elixirforum.com/t/how-to-create-an-http-proxy/60847/8 "2024-07-05T17:38:49Z")

</div>

I guess the confusion is `reverse_proxy_plug` could be considered a forward proxy given that it would be used to access an external website. However, it can still be considered a “reverse proxy” between the user & the elixir server.

---

<div class="post-metadata">

**Author:** ![jstimps](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/jstimps/32/41062_2.png) [@jstimps](https://forum.elixirforum.com/u/jstimps)\
**Post date:** [September 27, 2024, 11:12am UTC](https://forum.elixirforum.com/t/how-to-create-an-http-proxy/60847/10 "2024-09-27T11:12:11Z")

</div>

It sounds like you’re looking for an http server that supports the CONNECT protocol, such as the standalone app [squid](https://www.squid-cache.org/).

I haven’t personally seen any Erlang or Elixir http servers that have explicit documented support of HTTP CONNECT for proxying, but [cowboy does appear to support enable\_connect\_protocol for Websockets on HTTP2](https://ninenines.eu/docs/en/cowboy/2.6/manual/cowboy_http2/). Might take a bit of experimentation with cowboy’s configuration to determine if it suits your need.
