1 通过阿里云申请https证书
2 免费证书
3 几分钟后审核通过,将证书部署到服务器上:
4 nginx配置
upstream wowcp{ server 127.0.0.1:9511;}upstream wscp{ server 127.0.0.1:9513;}server { listen 443; server_name wow.0571sd.com; ssl on; ssl_certificate cert/cert-1542189031524_wow.0571sd.com.crt; ssl_certificate_key cert/cert-1542189031524_wow.0571sd.com.key; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; location /ws { #websocket配置 proxy_pass http://wscp; proxy_http_version 1.1; proxy_connect_timeout 4s; proxy_read_timeout 120s; proxy_send_timeout 10s; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; } location / { proxy_pass http://wowcp; } }
5 重启nginx
6 客户端连接websocket地址如:'wss://wow.0571sd.com/ws?ct=caipiao'