关于直播:直播可以使用-https-了快来试试吧

9次阅读

共计 1241 个字符,预计需要花费 4 分钟才能阅读完成。

当初文档中阐明不能应用 https,起因是须要配置 wss;上面咱们就具体阐明一下,认真看哦

第一步:nginx 配置 wss

nginx 配置参考

1、曾经装置 nginx,版本不低于 1.3

2、常识付费 Workerman 监听的是 20014 端口 (websocket 协定)

nginx 配置相似如下:

server {

  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;

 }


  # location / {} 站点的其它配置...}

第二步:批改 websocket 服务

配置实现后须要批改常识付费中根目录 public/wap/first/zsff/js/WebSocket.js 文件,用来区别 https 和 http 拜访

if (document.location.protocol == "https:"){that.ws = new WebSocket("wss://" + document.domain + "/wss/"+ ":" + port+'?uid='+window.uid+'&room='+window.room);

}else {that.ws = new WebSocket("ws://" + document.domain + ":" + port+'?uid='+window.uid+'&room='+window.room);

}

第三步:在宝塔中给常识付费站点配置证书,常识付费后盾根底配置下的网站网站链接改成 https;并且网站所有拜访链接均改成 https,包含微信公众号菜单等

第四步:应用命令 php think workerman status 查看 workerman 是否开启中,若是开启须要应用命令 php think workerman stop 敞开而后开启 workerman;如果敞开间接开启 workerman。

这样直播应用 https 就能够实现了

源码附件曾经打包好上传到百度云了,大家自行下载即可~

链接: https://pan.baidu.com/s/14G-b…
提取码: yu27
百度云链接不稳固,随时可能会生效,大家放松保留哈。

如果百度云链接生效了的话,请留言通知我,我看到后会及时更新~

开源地址
码云地址:
http://github.crmeb.net/u/defu

Github 地址:
http://github.crmeb.net/u/defu

开源不易,Star 以表尊重,感兴趣的敌人欢送 Star,提交 PR,一起保护开源我的项目,造福更多人!

正文完
 0