I'm trying to set up web sockets to go through Nginx to a Phoenix app but keep getting a 403 error. Can anyone advise the correct configuration to make this work in production - development env is fine.
My Nginx conf:
upstream phoenix {
server 127.0.0.1:4000 max_fails=5 fail_timeout=60s;
}
server {
server_name <app-domain>;
listen 80;
location / {
allow all;
# Proxy Headers
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Cluster-Client-Ip $remote_addr;
# The Important Websocket Bits!
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://phoenix;
}
}
My prod.exs conf:
use Mix.Config
config :logger, level: :info
config :phoenix, :serve_endpoints, true
config :app, App.Endpoint,
http: [port: 4000],
url: [host: "127.0.0.1", port: 4000],
root: '.',
cache_static_manifest: "priv/static/manifest.json",
server: true
config :app, App.Repo,
username: System.get_env("MONGO_USERNAME"),
password: System.get_env("MONGO_PASSWORD"),
database: "template",
hostname: "localhost",
pool_size: 10
I can provide any additional info as requested if necessary.
The app can be reached fine over the domain name, the last and only remaining problem is getting web sockets to work.
Many thanks to anyone who can point me in the right direction.