Configuring Nginx to work with websockets (Phoenix Channels)

I am learning a bit of Elixir lately and I am using websockets from the Phoenix web framework.
Everything worked on phoenix.server on localhost but I was unable to make it work when putting the app behind an Nginx proxy :(

400 Bad Request trying to connect to WebSocket server

I thought I did something wrong on the Elixir side because, you know, I am a newbie on that side.
Turns out nginx has to be configured with some extra information to work with websockets:

I added this to the phoenix github project in case anyone is stuck with this problem.

Leave a Comment

Your email address will not be published. Required fields are marked *