REXY

Reverse Proxy in Elixir

Reverse proxy built on top of plug.

Installation

If available in Hex, the package can be installed by adding rexy to your list of dependencies in mix.exs:

def deps do
  [{:rexy, "~> 0.1.0"}]
end

Fetaures

Configuration

All configuration is done throught :upstreams
In config/config.exs list your server to point to your wanted hosts

Example:

config :rexy,
       upstream: %{
         "load.com" => ["example.com", "google.bg"],
         "success.com" => {ReverseProxyTest.SuccessPlug, []},
         "api." => {ReverseProxyTest.SuccessPlug, []},
         "badgateway.com" => ["http://localhost:1"]
       }

We can route to a Plug, to a server, to a server built using Plug. If we have an array of servers, it will use the load balancer and rotate the servers every time we get a request.

If we want a domain proxy, then we just set the domain api..

You can embed it in other stuff

Just use Plug.Router.forward/2 to pass a route to the reverse proxy.

defmodule PlugReverseProxy.Router do
  use Plug.Router

  plug :match
  plug :dispatch

  forward "/users", to: ReverseProxy, upstream: ["dir.bg"]