nginx做反向代理连接https,但是连接不上

geloves
location /wss/
{
        proxy_pass http://127.0.0.1:7070;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        rewrite /wss/(.*) /$1 break;
        proxy_redirect off;
}

            function socketIo() {
                console.log('socketIo');
                var socket = io('https://www.***.com/wss/');

                // uid可以是自己网站的用户id,以便针对uid推送以及统计在线人数
                uid = "user_"+localStorage.id;
                // socket连接后以uid登录
                socket.on('connect', function() {
                    // 验证一下
                    console.log('socket 连接 '+uid);
                    socket.emit('login', uid);
                });
                // 后端推送来用户数据时
                socket.on('openAccount', function(msg) {
                    msg = msg.replace(/"/g, '"');
                    console.log("openAccount收到消息:"+msg);
                    msg = JSON.parse(msg);
                    if (!msg) {
                        console.log('服务端推送数据有误');
                        return;
                    }
//                  console.log("openAccount收到消息:"+JSON.stringify(msg));
                    localStorage.openstep = msg.openstep;
                    localStorage.account_state = msg.account_state;

                    if (msg.account_state == 1) {
                        console.log('account_state => '+localStorage.account_state);
                        app.toast('开户成功!');
                    } else if (msg.account_state == 3) {
                        console.log('account_state => '+localStorage.account_state);
                        app.toast('开户失败,请重新提交!');
                    }
                    var myCenter=  plus.webview.getWebviewById('myCenter');
                    setTimeout(function() {
                        //延迟2秒执行,防止重复
                        mui.fire(myCenter, 'loadUserInfo');
                    }, 2000);

                });
            }
5120 1 0
1个回答

walkor 打赏

新版本PHPSocket.io已经支持 SSL,可以不用nginx做代理了。
参考PHPSocket.IO手册
https://github.com/walkor/phpsocket.io/tree/master/docs/zh#支持sslhttps-wss

年代过于久远,无法发表回答
×
🔝