Having issues with getting Nginx to proxy_pass with websockets and SSL (WSS).
NGINX Config
server {
root /var/www/example.com/html;
index index.html index.htm index.nginx-debian.html;
server_name example.com www.example.com;
location / {
try_files $uri $uri/ =404;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.com/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
location /ws/ {
include proxy_params;
proxy_pass https://example.com:9090;
proxy_set_header Upgrade websocket;
proxy_set_header Connection Upgrade;
proxy_headers_hash_max_size 512;
proxy_headers_hash_bucket_size 128;
}
if ($scheme != "https") {
return 301 https://$host$request_uri;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
Need help!
Error:
index.js:9 Mixed Content: The page at ‘https://example.com/’ was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint ‘ws://example.com:9090/’. This request has been blocked; this endpoint must be available over WSS.
New contributor
Алексей Егоров is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.