workermna配置wss服务,注意通过宝塔的配置

1,apache

<VirtualHost *:443>
    ServerAdmin webmasterexample.com
    DocumentRoot "/www/wwwroot/daan163.com/"
    ServerName SSL.daancity.com
    ServerAlias www.daancity.com daancity.com 
    errorDocument 404 /404.html
    ErrorLog "/www/wwwlogs/daancity.com-error_log"
    CustomLog "/www/wwwlogs/daancity.com-access_log" combined
    
    #SSL
    SSLEngine On
    SSLCertificateFile /etc/letsencrypt/live/daancity.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/daancity.com/privkey.pem
    SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH
    SSLProtocol All -SSLv2 -SSLv3
    SSLHonorCipherOrder On
    
  
    
# Proxy Config
SSLProxyEngine on

ProxyRequests Off
ProxyPass /wss ws://127.0.0.1:8071
ProxyPassReverse /wss ws://127.0.0.1:8071

 

 

如果是apache的8072多群

# Proxy Config
SSLProxyEngine on

ProxyRequests Off
ProxyPass /wss2 ws://127.0.0.1:8072
ProxyPassReverse /wss2 ws://127.0.0.1:8072

 

注意php版本要取消某些函数的禁用

pcntl_fork   /  pcntl_signal_dispatch  /  pcntl_wait  /  pcntl_signal  /  pcntl_alarm

 

看云在线文档:https://www.kancloud.cn/bluestear/mdkeji_chat/1413237

多群版关闭ws
cd /www/wwwroot/www.mdkeji.cn/addons/mdkeji_chat/extend/Workerman-master/ && php start.php stop

多群版启动ws
cd /www/wwwroot/www.mdkeji.cn/addons/mdkeji_chat/extend/Workerman-master/ && php start.php start -d

 

 

2,nginx

  location /wss
  {
    proxy_pass http://127.0.0.1:8071;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
    proxy_set_header X-Real-IP $remote_addr;
  }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
WebSocket是一种在单个TCP连接上进行全双工通信的协议,常用于实时应用程序,如在线聊天、游戏等。WSS是WebSocket的加密版本,通过使用SSL/TLS协议来保护数据传输,提供了安全的通信环境。 配置WSS(WebSocket over SSL)通常涉及到以下几个步骤: 1. **服务器端设置**: - 使用支持SSL/TLS功能的服务器库,如Node.js的`https`模块或Java的Jetty。 - 创建一个HTTPS服务器,加载SSL证书和私钥。证书用于客户端验证服务器的身份,私钥用于加密和解密数据。 ```javascript (Node.js, using https module): const https = require('https'); const fs = require('fs'); const options = { key: fs.readFileSync('path/to/private.key'), cert: fs.readFileSync('path/to/certificate.crt'), port: 8443, requestCert: true, rejectUnauthorized: true, server: { ws: true }, }; https.createServer(options, (req, res) => { // WebSocket handling logic here }).listen(options.port); ``` 2. **WebSocket处理**: - 在服务器上启用WebSocket支持,监听`upgrade`请求,并转换为WebSocket连接。 ```javascript: if (req.method === 'GET' && req.url === '/ws') { req.socket.on('upgrade', (socket, head, req) => { // Upgrade to WebSocket connection const ws = new WebSocket.Server({ server: socket }); ws.on('connection', wsClient => { // Handle WebSocket client connections }); }); } ``` 3. **客户端连接**: - 客户端使用`wss`而不是`ws`来建立连接,URL前缀加上`s`表示加密。 ```javascript (JavaScript client): const wss = new WebSocket('wss://yourdomain.com/ws'); wss.addEventListener('open', () => { // Connection established }); ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

sunphp开发者

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值