diff --git a/README.md b/README.md index 16d52ea..71702ac 100644 --- a/README.md +++ b/README.md @@ -22,3 +22,23 @@ task进程数可以根据需要多开一些,默认为10
9.另外,部署到香港、韩国、日本等非大陆的服务器的事情就不用我说了吧。推荐使用:www.vultr.com日本服务器
10.如果您也搭建了此服务,我们可以互粉一下友情链接,组合成一个阵营,互粉群:G.widora.cn 互粉群 +####nginx转发ws or wss示例 + ``` + upstream websocket { + server 127.0.0.1:8848; + } + server { + ...//...代表您的nginx其他配置 + + location /wss { + proxy_pass http://websocket; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "Upgrade"; + } + + } +//配置完成后,修改 style/js/index.js中连接ws部分为: +// __this.ws = new WebSocket("ws" + (ishttps ? "s": "") + "://" + document.domain + "/wss"); //nginx配置ssl做8848转发 +``` + diff --git a/staticweb/js/index.js b/staticweb/js/index.js index d071359..eba9bbd 100644 --- a/staticweb/js/index.js +++ b/staticweb/js/index.js @@ -5,7 +5,9 @@ var webSocketClick = { init:function(){ var __this = this; __this.app_block = $(".app-block"); - __this.ws = new WebSocket("wss://" + document.domain + ":8848"); + var ishttps = 'https:' == document.location.protocol ? true: false; + __this.ws = new WebSocket("ws" + (ishttps ? "s": "") + "://" + document.domain + ":8848"); + // __this.ws = new WebSocket("ws" + (ishttps ? "s": "") + "://" + document.domain + "/wss"); //nginx配置ssl做8848转发 __this.ws.onopen = function(event){ __this.onOpen(event) }