Debes intentar con esto:
Agrega este bloque:
upstream websocket {
server localhost:5000;
}
y usa esta expresión regular para que el websocket el cual realmente viaja sobre http/https con la funcionalidad activa de always-connected
location /subTextoWSUrl/ {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;
}
por ejemplo:
**wss://**miserver.com/subTextoWSUrl/a/b/c/d.ejemplo.
Este es mi archivo de configuración:
server {
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name miserver.com.co www.miserver.com.co;
client_max_body_size 100M;
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /subTextoWSUrl/ {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;
}
listen [::]:443 ssl ipv6only=on;
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/miserver.com.co/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/miserver.com.co/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
server {
if ($host = miserver.com.co) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = www.miserver.com.co) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 default_server;
listen [::]:80 default_server;
server_name miserver.com.co www.miserver.com.co;
return 404;
}