Nginx Ratchet通过https连接到websocket服务器时出现一些错误

问题描述

我正在使用nginx服务器,并且有多个站点正在运行。我正在尝试设置Websocket服务器。
这是我正在使用的服务器配置

上游websocketserver {
服务器website.com:8082;
}
服务器{

             listen [::]:443 ssl http2;
             listen 443 ssl http2;

             server_name website.com;
             index index.php index.html index.htm;

             charset utf-8;
             client_max_body_size 50M;

             root /var/www/website.com;

             # Pass PHP scripts to the cgi server
             location ~ [^/]\.php(/|$) {
                     fastcgi_split_path_info ^(.+?\.php)(/.*)$;
                     fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
                     fastcgi_index index.php;
                     include snippets/fastcgi-php.conf;
             }

             location ~ /\.ht {
                     deny all;
             }

             ssl on;
             ssl_certificate path/cert.pem; 
             ssl_certificate_key path/privkey.pem;

             location /website.com {

                     # switch off logging
                      access_log off;

                     proxy_pass http://websocketserver;
                     proxy_http_version 1.1;
                     proxy_set_header Upgrade $http_upgrade;
                     proxy_set_header Connection "Upgrade";
                     proxy_set_header Host $host;

                     proxy_set_header X-Real-IP $remote_addr;
                     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                     proxy_set_header X-Forwarded-Proto https;
                     proxy_read_timeout 86400s;
                     proxy_send_timeout 86400s;
                     keepalive_timeout 86400s;
                     proxy_redirect off;
              }

}

Websocket服务器设置

$ app = new Ratchet \ App(“ localhost”,8082,'0.0.0.0');
$ app-> route('/ chat',new Chat,array('*'));
$ app-> run();

客户端脚本

var conn = new WebSocket('wss://website.com');

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)