需要在config/autoload/server.php 文件中设置
type => Server::SERVER_WEBSOCKETsock_type => SWOOLE_SOCK_TCP | SWOOLE_SSL'settings' => [ 'open_websocket_protocol' => false, 'ssl_cert_file' => '', // 请替换为实际证书路径 'ssl_key_file' => '', // 请替换为实际私钥路径 ],
openssl s_client -connect www.baidu.com:443 -tls1_2
检测nginx配置证书是否正确
nginx配置
ssl_certificate 证书key; ssl_certificate_key 证书私钥地址; location /wss/ { proxy_pass http://127.0.0.1:9501; # 注意:这里不使用 wss://,因为 Nginx 已经处理了前端的 SSL 加密 proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; }