Nginx wss ws Ratchet problem.
Hello i hope you'll understand me because my english i snot perfect :)

I'm trying to install Ratchet on a webserver with nginx and CloudPanel

I'd read a lot of different conf but nothing work for me :( :(

For information i have the same on a webserver where i'm not doing the conf file.... and it work on it's other server.

This my conf file :


`upstream websocket{
 server 127.0.0.1:10002;
}

map $http_upgrade $connection_upgrade {
 default Upgrade;
 '' close;
}
server {
  listen 80;
  listen [::]:80;
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  {{ssl_certificate_key}}
  {{ssl_certificate}}
  server_name sousdomaine.xxxxxxxx.com;
  {{root}}
  
  {{nginx_access_log}}
  {{nginx_error_log}}

  if ($bad_bot = 1) {
    return 403;
  }

  if ($scheme != "https") {
    rewrite ^ https://$host$uri permanent;
  }
  
  location ~ /.well-known {
    auth_basic off;
    allow all;
  }

  {{basic_auth}}

  try_files $uri $uri/ /index.php?$args;
  index index.php index.html;

location /ws/ {
    proxy_pass http://websocket;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
            proxy_redirect off;
            proxy_read_timeout 86400s;
            proxy_send_timeout 86400s;
            keepalive_timeout 86400s;
            # prevents 502 bad gateway error
            proxy_buffers 8 32k;
            proxy_buffer_size 64k;
            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;
            reset_timedout_connection on;
}

  location ~ \.php$ {
    include fastcgi_params;
    fastcgi_intercept_errors on;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    try_files $uri =404;
    fastcgi_read_timeout 3600;
    fastcgi_send_timeout 3600;
    fastcgi_param HTTPS $fastcgi_https;
    {{php_fpm_listener}}
    {{php_settings}}
  }

  location ~* ^.+\.(css|js|jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|eot|mp4|ogg|ogv|webm|webp|zip|swf)$ {
    add_header Access-Control-Allow-Origin "*";
    expires max;
    access_log off;
  }
  
  include /home/cloudpanel/htdocs/sousdomaine.xxxxxx.com/rewrite-nginx.conf;
  
  if (-f $request_filename) {
    break;
  }
  
}`

as you can see it's a template.
All {{ var }} are correct.

my js part is :

`var conn = new WebSocket('wss://sousdomaine.xxxxxxxx.com:10002/ws/');`

and the error is :

websocket connection to 'wss://sousdomaine.xxxxxxxxx.com:10002/ws/' failed.
Of course i'm starting ratchet server ;) and it's OK it running.

Please help



