Websockets to Nginx reverse proxy

I’m using Nginx to terminate ssl and reverse proxy to my phoenix application, which I’m deploying via docker. The web traffic works fine, but websockets are giving me the business.

I get a 403 forbidden when the socket tries to connect. I’m suspecting it’s something to do with my config, which is

config :exertion, Exertion.Endpoint,
  http: [port: {:system, "PORT"}],
  url: [host: "exertion.io", port: {:system, "PORT"}],
  cache_static_manifest: "priv/static/manifest.json"

I’ve configured nginx as recommended to proxy websocket connections.

Can you tell if that 403 is from your application or from nginx?

It’s was coming from the application. I feel incredibly stupid, but the reason it was erroring out is because I was providing “localhost” as one of the arguments to check_origin, rather than 127.0.0.1

1 Like