Laravel-reverb:cURL 错误 56:连接后从代理收到 HTTP 代码 503

问题描述 投票:0回答:1

我正在尝试使用 laravel reverb ( localhost ),但作业失败并出现此错误:

GuzzleHttp\Exception\RequestException: cURL error 56: Received HTTP code 503 from proxy after CONNECT (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://sockets.my-app/apps/154811/events?auth_key=ht3fidxq3ibryisgbwvs&auth_timestamp=1713439684&auth_version=1.0&body_md5=4d4063e1f80149f3f49cd0ca8f7b0e9b&auth_signature=09cc000f73028b8a2f0467bbdac413153847ad336247071a111c64f63aa2f289 in /var/www/may-app/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:211

我的.env

...
REVERB_HOST="sockets.my-app"
REVERB_PORT=443
REVERB_SCHEME=https
REVERB_SERVER_HOST=0.0.0.0
REVERB_SERVER_PORT=8080
...

这是我的 NGINX 配置:

server {
   listen 443;
   listen [::]:443;
   server_name sockets.my-app;

    ssl on;
    ssl_certificate /etc/ssl/certs/***.fr.cer;
    ssl_certificate_key /etc/ssl/private/***.fr.key;
    ssl_session_timeout 5m;
    ssl_protocols TLSv1.2;
    ssl_ciphers HIGH:3DES:!aNULL:!MD5:!SEED:!IDEA;
    ssl_prefer_server_ciphers on;

    location / {
        proxy_http_version 1.1;
        proxy_set_header Host $http_host;
        proxy_set_header Scheme $scheme;
        proxy_set_header SERVER_PORT $server_port;
        proxy_set_header REMOTE_ADDR $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_pass http://0.0.0.0:8080;
    }
}

我在我的控制器中调度我的事件,如下所示:

CommentCreated::dispatch($comment);

所以我可以看到作业失败了:

2024-04-18 12:24:37 ***\***\app\Events\CommentCreated ................ RUNNING
2024-04-18 12:24:37 ***\***\app\Events\CommentCreated ............. 14.97ms FAIL

有人知道我缺少什么部分吗?预先感谢

laravel laravel-reverb
1个回答
0
投票

我终于找到了解决办法。我把它放在这里,如果有帮助的话。

这个想法是在同一台机器上运行网络服务器和混响。 我使用 nginx 反向代理充当用户和混响之间的中介。

.env

REVERB_HOST="sockets.my-domain.com"
REVERB_PORT=443
REVERB_SCHEME=https
REVERB_SERVER_HOST=127.0.0.1
REVERB_SERVER_PORT=8080
REVERB_SERVER_SCHEME=http

VITE_REVERB_SERVER_HOST='${REVERB_SERVER_HOST}'
VITE_REVERB_SERVER_PORT='${REVERB_SERVER_PORT}'
VITE_REVERB_SERVER_SCHEME='${REVERB_SERVER_SCHEME}'
VITE_REVERB_APP_KEY="${REVERB_APP_KEY}"
VITE_REVERB_HOST="${REVERB_HOST}"
VITE_REVERB_PORT="${REVERB_PORT}"
VITE_REVERB_SCHEME="${REVERB_SCHEME}"

资源/js/echo.js

import Echo from 'laravel-echo';

import Pusher from 'pusher-js';
window.Pusher = Pusher;

window.Echo = new Echo({
   broadcaster: 'reverb',
   key: import.meta.env.VITE_REVERB_APP_KEY,
    wsHost: import.meta.env.VITE_REVERB_HOST,
    wsPort: import.meta.env.VITE_REVERB_PORT ?? 80,
    wssPort: import.meta.env.VITE_REVERB_PORT ?? 443,
    forceTLS: (import.meta.env.VITE_REVERB_SCHEME ?? 'https') === 'https',
    enabledTransports: ['ws', 'wss'],
});

配置/广播

    'reverb' => [
        'driver' => 'reverb',
        'key' => env('REVERB_APP_KEY'),
        'secret' => env('REVERB_APP_SECRET'),
        'app_id' => env('REVERB_APP_ID'),
        'options' => [
            'host' => env('REVERB_SERVER_HOST'),
            'port' => env('REVERB_SERVER_PORT', 443),
            'scheme' => env('REVERB_SERVER_SCHEME', 'https'),
            'useTLS' => env('REVERB_SERVER_SCHEME', 'https') === 'https',
        ],
        'client_options' => [
            'verify' => false,
        ],

配置/混响

 'apps' => [
        [
            'key' => env('REVERB_APP_KEY'),
            'secret' => env('REVERB_APP_SECRET'),
            'app_id' => env('REVERB_APP_ID'),
            'options' => [
                'host' => env('REVERB_SERVER_HOST'),
                'port' => env('REVERB_SERVER_PORT', 443),
                'scheme' => env('REVERB_SERVER_SCHEME', 'https'),
                'useTLS' => env('REVERB_SERVER_SCHEME', 'https') === 'https',
            ],
            'allowed_origins' => ['*'],
            'ping_interval' => env('REVERB_APP_PING_INTERVAL', 60),
            'max_message_size' => env('REVERB_APP_MAX_MESSAGE_SIZE', 10_000),
        ],

conf NGINX

server {
   listen 443;
   listen [::]:443;
  server_name sockets.my-domain.com;

ssl on;
ssl_certificate /etc/ssl/certs/****.fr.cer;
ssl_certificate_key /etc/ssl/private/****.fr.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1.2;
ssl_ciphers HIGH:3DES:!aNULL:!MD5:!SEED:!IDEA;
ssl_prefer_server_ciphers on;

location / {
    proxy_http_version 1.1;
    #proxy_set_header Host $http_host;
    proxy_set_header Scheme $scheme;
    proxy_set_header SERVER_PORT $server_port;
    proxy_set_header REMOTE_ADDR $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto https;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
    proxy_pass http://0.0.0.0:8080;
    }
}

效果很好

© www.soinside.com 2019 - 2024. All rights reserved.