reverse_proxy_plug icon indicating copy to clipboard operation
reverse_proxy_plug copied to clipboard

Websocket support?

Open focused opened this issue 5 years ago • 8 comments

This the most awesome package for proxying, but it does not work with websockets, the error code 426 Upgrade Required received when i try to proxy "ws://" request. I found that "connection" and "upgrade" are disabled in remove_hop_by_hop_headers function. Are you going to support WS?

focused avatar Aug 22 '19 16:08 focused

Hi, thanks for your interest!

This is definitely something we would like to implement properly, but unfortunately it is not on our priority list right now. In the meantime we welcome pull requests towards this.

msz avatar Aug 29 '19 13:08 msz

Any recommendations to start this issue ? Websockex as client ? Purely forwarding the frames TCP ?

minidfx avatar Sep 21 '22 16:09 minidfx

Soon as this pull request(https://github.com/elixir-plug/plug_cowboy/pull/88) is merged, I will try to implement the websocket proxying with gun(https://github.com/ninenines/gun) as internal client for proxing frames to the upstreams.

minidfx avatar Oct 22 '22 06:10 minidfx

Ok the support for the websocket has been merged into plug_cowboy: https://hexdocs.pm/plug_cowboy/Plug.Cowboy.html#module-websocket-support

minidfx avatar Nov 01 '22 08:11 minidfx

@minidfx I am interested in proxying websockets too, did you manage to find a solution?

hubertlepicki avatar Mar 23 '23 11:03 hubertlepicki

Yep, I moved to nginx ;)

minidfx avatar Mar 24 '23 12:03 minidfx

@minidfx attaboy ;). Okay in that case I need to give it a shot myself as I need it done programmatically :/

hubertlepicki avatar Mar 24 '23 12:03 hubertlepicki

But you can check the package plug_cowboy, recently the support of the websocket was added, it was really not easy to send the messages to the backend server and reply to the clients.

I spend too much time without a good result with websocket in this project: https://github.com/minidfx/elixir-reverse-proxy

Useful links:

  • https://github.com/elixir-plug/plug_cowboy
  • https://ninenines.eu/docs/en/cowboy/2.9/guide/ws_protocol/
  • https://hexdocs.pm/plug_cowboy/Plug.Cowboy.html#module-websocket-support

Have fun!

minidfx avatar Mar 29 '23 06:03 minidfx