微信小程序支持wss

有一个旧的websocket服务器,不支持wss.

单微信小程序要求支持wss. 所以需要部署一个nginx中转把wss协议proxy到旧的服务器上

server {
        listen       8443 ssl http2 default_server;
        listen       [::]:8443 ssl http2 default_server;
        server_name  www.mydomain.com:8443;
        root         /usr/share/nginx/html;

        ssl_certificate "xxxxx.pem";
        ssl_certificate_key "xxxxx.key";
        ssl_session_cache shared:SSL:1m;
        ssl_session_timeout  10m;
        ssl_ciphers HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers on;
        location / {
                proxy_pass http://127.0.0.1:8080;#代理到上面的地址去
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "Upgrade";
                }

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;


        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

你可能感兴趣的:(微信小程序支持wss)