Docker Laravel Websockets - 连接在收到握手响应前关闭

Docker Laravel Websockets - Connection closed before receiving a handshake response

我有一个 Docker 环境 运行ning Laravel 我想让 laravel-websockets 工作。

当我访问这里时:

http://localhost:8000/laravel-websockets

我收到以下错误:

开发工具为我提供了以下内容:

WebSocket connection to 'ws://localhost:6001/app/local?protocol=7&client=js&version=4.3.1&flash=false' failed: Connection closed before receiving a handshake response

我有以下 docker-compose.yaml:

version: "3.8"

services:
    server:
        build:
            context: .
            dockerfile: dockerfiles/nginx.dockerfile
        ports:
            - "8000:80"
            - "6001:6001"
        volumes:
            - ./src:/var/www/html
            - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro
        depends_on:
            - app
    app:
        build:
            context: .
            dockerfile: dockerfiles/php.dockerfile
        volumes:
            - ./src:/var/www/html:delegated

我的 php.dockerfile 看起来是这样的:

FROM php:8.0-fpm-alpine

USER root

WORKDIR /var/www/html

COPY src .

RUN apk --no-cache add libxml2-dev
RUN docker-php-ext-install soap
RUN docker-php-ext-install pdo pdo_mysql

RUN echo 'max_execution_time = 120' >> /usr/local/etc/php/conf.d/docker-php-maxexectime.ini;

EXPOSE 6001

我绝不是专家,所以我可能遗漏了一些明显的东西。任何帮助表示赞赏。

============

编辑:附加信息

在本地设置:

'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'),
            'encrypted' => false,
            'host' => '127.0.0.1',
            'port' => 6001,
            'scheme' => 'http'
        ],
    ],

我 运行:

php artisan websockets:serve

抱歉,我很笨

services:
    server:
        build:
            context: .
            dockerfile: dockerfiles/nginx.dockerfile
        ports:
            - "8000:80"
            - "6001:6001"   <<<<<<<<

端口 6001 需要暴露在我的应用程序容器上,而不是在服务器上:

services:
    app:
        build:
            context: .
            dockerfile: dockerfiles/php.dockerfile
        ports:
            - "6001:6001"   <<<<<<<<