reverse_proxy_plug
reverse_proxy_plug copied to clipboard
Cannot get proxy to work with Tesla adapter
Hello,
I am trying out this plug, and ran into a strange issue. Configuring tesla_client option was also kind of tricky, and I don't know if I have it setup correctly. The problem I see is that when configured with Tesla (using either mint or hackney as tesla_client), the requests just hang and never complete. Using hackney directly instead of tesla seems to work.
Here's how I have it setup:
mix.exs:
defp deps do
[
{:reverse_proxy_plug, "~> 2.1"},
{:tesla, "~> 1.4"},
{:mint, "~> 1.4"},
{:castore, "~> 0.1"}
]
end
endpoint.ex:
defmodule MiddleMan.Endpoint do
use Plug.Router
plug(Plug.Telemetry, event_prefix: [:middle_man, :plug])
plug(Plug.Logger)
plug(:match)
plug(:dispatch)
get "/hello" do
send_resp(conn, 200, "world")
end
forward("/test",
to: ReverseProxyPlug,
client: ReverseProxyPlug.HTTPClient.Adapters.Tesla,
upstream: "//localhost:8000/",
client_options: [
tesla_client: Tesla.client([], {Tesla.Adapter.Mint, []})
]
)
end
When I make a request to http://localhost:4000/test/test.json, I see this in the logs:
15:21:59.484 [info] GET /test/test.json
and the browser keeps loading and loading with no response.
Any clues what I did wrong above? I was unable to figure out how to pass tesla_client option in config.exs, so I ended up passing the options in the forward call.
Any help would be appreciated.....thanks for your time!