终于明白了,这是我的
laravel-echo-server.json:
{ "authHost": "https://example-domain.com", "authEndpoint": "/broadcasting/auth", "clients": [ { "appId": "xxxxxxx", "key": "xxxxxxxxxxxxxx" } ], "database": "redis", "databaseConfig": { "redis": { "port": "6379", "host": "localhost" }, "sqlite": {} }, "devMode": true, "host": "localhost", "port": "6001", "protocol": "http", "socketio": {}, "sslCertPath": "/path/to/ssl/crt/crt.pem", // or .crt "sslKeyPath": "/path/to/ssl/key/crt.pem", // or .key "sslCertChainPath": "", "sslPassphrase": "", "subscribers": { "http": true, "redis": true }, "apiOriginAllow": { "allowCors": true, "allowOrigin": "*", "allowMethods": "GET, POST", "allowHeaders": "Origin, Content-Type, X-Auth-Token, X-Requested-With, Accept, Authorization, X-CSRF-TOKEN, X-Socket-Id" }}我如何使用laravel-echo-server.json:
import Echo from "laravel-echo";window.io = require('socket.io-client');// Have this in case you stop running your laravel echo serverif (typeof io !== 'undefined') { window.Echo = new Echo({ broadcaster: 'socket.io', host: window.location.hostname, });}在
virtualhost我的域的SSL中的我的apaxhe配置:
RewriteEngine onRewriteCond %{REQUEST_URI} ^/socket.io [NC]RewriteCond %{QUERY_STRING} transport=websocket [NC]RewriteRule /(.*)ws://localhost:6001/$1 [P,L]ProxyPass /socket.io http://localhost:6001/socket.ioProxyPassReverse /socket.io http://localhost:6001/socket.io


