phoenix + websockets的nginx配置是否正确?

vwoqyblh  于 2023-04-20  发布在  Nginx
关注(0)|答案(1)|浏览(119)

我看到socket.js:229 WebSocket connection to 'ws://sitename.io/socket/websocket?token=&vsn=2.0.0' failed:,想知道是不是因为nginx。
下面是我nginx配置:

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name sitename.io;

    location /socket/websocket/ {
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_pass http://localhost:4000/socket/websocket;
        }

    location / {
            proxy_pass http://localhost:4000/;
    }
}

相关问题