API Reverse Proxy in Phoenix

Hi everyone. I was doing some work recently on ways to get Elixir into production, and I ended up building a reverse proxy as a middle-man between the clients and the current production API.

I put it all in this repository for anybody to run with: https://github.com/fourkio/reverse_proxy_elixir_phoenix

I also wrote up an article that goes into a little more detail about how it’s setup and how it can be modified for more customized uses:https://blog.fourk.io/replace-your-production-api-with-elixir-today-4426a8903642

I know it’s obviously not perfect, but I would love to get feedback and ideas from everyone!

4 Likes

It seems really strange to overload the ErrorView like this. :confused: I wrote a API reverse proxy in Phoenix recently and handled the API request/response within a controller dedicated to a particular API server. I used the router to capture the API endpoint and subsequent options to pass on to the external API – nesting the route scopes helped logically organize the APIs. The API tokens and hostname were stored in config – not hard-coded in the view; although as I scale it out, this config will reside in a DB somewhere.

Thanks for sharing! Your approach has given me some ideas to consider integrating in my own application.

1 Like