# REXY
## Reverse Proxy in Elixir
Reverse proxy built on top of plug.
## Installation
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `rexy` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[{:rexy, "~> 0.1.0"}]
end
```
## Fetaures
- Load Balancing(just use round robin for now)
- Domain based proxying(doesn't matter whether it's localhost or some other domain)
- Path based proxying(configuration in config.exs)
- SSL/TLS termination(just delete some headers)
## Configuration
All configuration is done throught `:upstreams`
In config/config.exs list your server to point to your wanted hosts
Example:
```elixir
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.
```elixir
defmodule PlugReverseProxy.Router do
use Plug.Router
plug :match
plug :dispatch
forward "/users", to: ReverseProxy, upstream: ["dir.bg"]
```