@thisall

Как заставить работать Laravel WebSocket?

Пытаюсь запустить dashboard и выдаёт ошибку. Хочу запустить на https

pusher.min.js:8 WebSocket connection to 'wss://chat.domain.ru:6001/app/1234?protocol=7&client=js&version=7.0.2&flash=false' failed: WebSocket opening handshake was canceled


broadcasting.php

'pusher' => [
            'driver' => 'pusher',
            'key' => env('PUSHER_APP_KEY'),
            'secret' => env('PUSHER_APP_SECRET'),
            'app_id' => env('PUSHER_APP_ID'),
            'options' => [
                'cluster' => env('PUSHER_APP_CLUSTER'),
                'host' => '127.0.0.1',
                'post' => 6001,
                'scheme' => 'https',
                'curl_options' => [
                    CURLOPT_SSL_VERIFYHOST => 0,
                    CURLOPT_SSL_VERIFYPEER => 0,
                ]
            ],
        ],


websockets.php

'apps' => [
        [
            'id' => env('PUSHER_APP_ID'),
            'name' => env('APP_NAME'),
            'key' => env('PUSHER_APP_KEY'),
            'secret' => env('PUSHER_APP_SECRET'),
            'enable_client_messages' => true,
            'enable_statistics' => true,
        ],
    ],


.env

APP_URL=http://chat.domain.ru
PUSHER_APP_ID=1234
PUSHER_APP_KEY=1234
PUSHER_APP_SECRET=1234
PUSHER_APP_CLUSTER=eu
PUSHER_APP_HOST=127.0.0.1


nginx conf

map $http_upgrade $type {
    default "web";
    websocket "ws";
}

server {

	server_name chat.domain.ru;

	root /var/www/nginx/chat/public;
	index index.php index.html;

    index index.php;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    charset utf-8;

    location @web {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location @ws  {
        proxy_pass             https://127.0.0.1:6001;
        proxy_set_header Host  $host;
        proxy_read_timeout     60;
        proxy_connect_timeout  60;
        proxy_redirect         off;

        # Allow the use of websockets
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }

    listen 443 ssl;
}


Может кто сталкивался с такой проблемой
  • Вопрос задан
  • 983 просмотра
Решения вопроса 1
@thisall Автор вопроса
Решил проблему, выставив ssl сертификат в config/websockets.php ['ssl']
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы