1

1 通过阿里云申请https证书
图片描述

2 免费证书
图片描述

3 几分钟后审核通过,将证书部署到服务器上:
图片描述

4 nginx配置

upstream wowcp{
        server 127.0.0.1:9511;
}
upstream wscp{
        server 127.0.0.1:9513;
}
server {
    listen 80;
    server_name spr.xxxx.vip;
    root /var/www/spr;
    index index.html index.htm;
   
    
    listen 443 ssl;
    #ssl on;
    ssl_certificate      cert/2827994_spr.rdc359.vip.pem;
    ssl_certificate_key  cert/2827994_spr.rdc359.vip.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 / {
        root /var/www/spr;
        index index.html index.htm;
    }
}

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'


hufeng
291 声望21 粉丝