node.js - 获取 ERR_CONNECTION_TIMED_OUT Laravel 回显服务器
问题描述
Laravel echo 在 localhost 上工作,但在使用 cloudflare ssl 的生产中却不行。我得到连接超时。
我的配置如下。
laravel 回显服务器 json:
{
"authHost": "https://example.com",
"authEndpoint": "/broadcasting/auth",
"clients": [
{
"appId": "xxxxxxxxx",
"key": "xxxxxxxxxxxxx"
}
],
"database": "redis",
"databaseConfig": {
"redis": {},
"sqlite": {
"databasePath": "/database/laravel-echo-server.sqlite"
}
},
"devMode": false,
"host": "localhost",
"port": "6001",
"protocol": "https",
"socketio": {},
"sslCertPath": "/etc/ssl/certs/cert.pem",
"sslKeyPath": "/etc/ssl/private/key.pem",
"sslCertChainPath": "",
"sslPassphrase": "",
"subscribers": {
"http": true,
"redis": true
},
"apiOriginAllow": {
"allowCors": true,
"allowOrigin": "https://example.com:70",
"allowMethods": "GET, POST",
"allowHeaders": "Origin, Content-Type, X-Auth-Token, X-Requested-With, Accept, Authorization, X-CSRF-TOKEN, X-Socket-Id"
}
}
这是我的整个 nginx 配置:
server {
listen 80;
listen [::]:80;
server_name example.com www.example.com;
return 302 https://$server_name$request_uri;
#rewrite ^(.*) https://domain$1 permanent;
}
server {
#SSL configuration
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl on;
ssl_certificate /etc/ssl/certs/cert.pem;
ssl_certificate_key /etc/ssl/private/key.pem;
root /var/www/example/public;
index index.php;
client_max_body_size 100M;
charset utf-8;
gzip on;
gzip_vary on;
gzip_disable "msie6";
gzip_comp_level 6;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_proxied any;
gzip_types
text/plain
text/css
text/js
text/xml
text/javascript
application/javascript
application/x-javascript
application/json
application/xml
application/xml+rss;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location /socket.io {
proxy_pass http://localhost:6001;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
location ~ \.php$ {
#include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
#fastcgi_read_timeout 300;
}
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|svg|woff|woff2|ttf)\$ {
expires 1M;
access_log off;
add_header Cache-Control "public";
}
location ~* \.(?:css|js)\$ {
expires 7d;
access_log off;
当我运行 laravel-echo-server start 我得到
✔ Running at localhost on port 6001
✔ Channels are ready.
✔ Listening for http events...
✔ Listening for redis events...
在前端控制台上,我得到连接超时。如果我将 laravel echo 设置为开发模式,我会在终端中收到事件,但在前端控制台上仍然会出现连接超时。
似乎是 nginx 部分的错误配置。
那么我该怎么做才能让它发挥作用呢?
解决方案
推荐阅读
- python - 在 numpy 上测试位
- javascript - 浏览器 IE11 JavaScript 让 [...document.querySelectorAll 语法错误
- flutter - ChangeNotifierProvider 显示灰屏
- python - 玩家在 pygame 中使用 player.jump 只跳跃一次
- vue.js - Asp.net core 3.1 后端没有从 cookie 中获取身份
- excel - excel最小值不同于0,使得下一个值为0
- php - 如何在 laravel 中获取 url 参数?
- swift - 如何摆脱 SwiftUI TextFields 周围的蓝色选择边框?
- python - 我们可以使用 Python 中的 Quandl 库获得印度股市的股票调整价格吗?
- python-3.x - 如何使用python查找字符串中重复次数第二多的字符