1.站點(diǎn)偽靜態(tài)加wss配置
location /wss {
proxy_pass http://127.0.0.1:20014;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
}
2. 移動(dòng)端修改文件,改成下面這樣
if (document.location.protocol == "https:") {
that.ws = new WebSocket("wss://" + document.domain + "/wss"+'?uid='+window.uid+'&room='+window.room);
} else {
that.ws = new WebSocket("ws://" + document.domain + ":" + port+'?uid='+window.uid+'&room='+window.room);
}
3. pc端修改文件
var url = '';
if(window.location.protocol.indexOf('https') == -1) {
url = window.location.protocol.replace('http', 'ws') + '//' + window.location.hostname;
}else{
url = window.location.protocol.replace('https', 'wss') + '//' + window.location.hostname + '/wss';
}
if (options.port) {
if (window.location.protocol.indexOf('wss') == -1) {
url += ':' + options.port;
}
}
4.在寶塔中給知識(shí)付費(fèi)站點(diǎn)配置證書(shū),知識(shí)付費(fèi)后臺(tái)基礎(chǔ)配置下的網(wǎng)站網(wǎng)站鏈接改成https;并且網(wǎng)站所有訪問(wèn)鏈接均改成https,包括微信公眾號(hào)菜單等
5.使用命令php think workerman status檢查workerman是否開(kāi)啟中,若是開(kāi)啟需要使用命令php think workerman stop 關(guān)閉然后開(kāi)啟workerman;如果關(guān)閉直接開(kāi)啟workerman。
這樣直播使用https就可以實(shí)現(xiàn)了