View Source MainProxy.Proxy behaviour (main_proxy v0.2.0)

Defines a proxy

Allows defining an http and/or https proxy.

Basic example:

defmodule MyApp.Proxy do
  use MainProxy.Proxy
end

Example with SiteEncrypt:

defmodule MyApp.Proxy do
  use MainProxy.Proxy

  @impl MainProxy.Proxy
  def merge_config(:https, opts) do
    Config.Reader.merge(opts, SiteEncrypt.https_keys(MyAppWeb.Endpoint))
  end

  def merge_config(_, opts), do: opts
end

Link to this section Summary

Callbacks

Specify the backends to pass requests to at startup time. (Optional)

Merge cowboy config

Link to this section Types

Specs

scheme() :: :http | :https

Link to this section Callbacks

Specs

backends() :: [map()]

Specify the backends to pass requests to at startup time. (Optional)

Overriding this callback allows for setting the backends to be matched at runtime when the proxy is starting up.

Example:

@impl MainProxy.Proxy
def backends do
  [
    %{
      domain: "https://myapp1.com",
      phoenix_endpoint: MyApp1Web.Endpoint
    },
    %{
      domain: "https://myapp2.com",
      phoenix_endpoint: MyApp2Web.Endpoint
    }
  ]
end
Link to this callback

merge_config( scheme, keyword )

View Source (optional)

Specs

merge_config(
  scheme(),
  keyword()
) :: keyword()

Merge cowboy config

Overriding this callback allows the configuration from the application environment to be modified at runtime.