Websockets isn't working on the deployed version
omgmog opened this issue · comments
Max Glenister commented
It's likely an issue with nginx.
The browser complains:
WebSocket connection to 'wss://sound.me.uk/' failed: Unexpected response code: 200
You can see how the app starts the backend api here:
https://github.com/omgmog/sound-dropper/blob/main/server.js
https://github.com/omgmog/sound-dropper/blob/main/server/api.js
so it should be exposing the websockets on :3000
Here is the nginx config for the server:
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream websocket {
server localhost:3000;
}
server {
server_name sound.me.uk www.sound.me.uk;
#access_log /var/log/nginx/host.access.log main;
location / {
proxy_pass http://websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location ~ /\.ht {
deny all;
}
location ~ /\.git {
deny all;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/sound.me.uk/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/sound.me.uk/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
# and there's a further server definition from certbot that listens on 80 and handles redirects to port 443