部署过程中遇到以下异常
Mixed Content: The page at 'https://www.xxx.com' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws://www.xxx.com:8084/socket.io/?&EIO=3&transport=websocket'. This request has been blocked; this endpoint must be available over WSS.
服务端:socketIO
目标:实现wss支持
方案:配置Nginx
upstream websocket {
// 内网websocket IP地址
server 192.168.0.235:8084;
}
server {
resolver 8.8.8.8;
ssl_stapling on;
ssl_stapling_verify on;
listen 443 ssl;
server_name www.xxx.com;
proxy_buffering off;
ssl on;
ssl_certificate /etc/nginx/newtranx.com/fullchain.pem;
ssl_certificate_key /etc/nginx/newtranx.com/privkey.pem;
// 此处省略其他配置
location /socket.io {
proxy_pass http://websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
}
ps: proxy_pass http://websocket
中的websocket
对应upstream
后面的名称
参考:https://blog.csdn.net/chopin407/article/details/52937645
网友评论