Skip to content

Instantly share code, notes, and snippets.

@adityadees
Last active May 17, 2024 05:45
Show Gist options
  • Save adityadees/87693d7bc70527f4a50923e1600de5d1 to your computer and use it in GitHub Desktop.
Save adityadees/87693d7bc70527f4a50923e1600de5d1 to your computer and use it in GitHub Desktop.
apache reverse proxy laravel echo server
- npm install pm2 -g
- pm2 start echo-server.json --name="apps"
```echo-server.json
{
"name": "apps",
"script": "laravel-echo-server",
"args": "start"
}
```
{
"authHost": "https://domainName.com",
"authEndpoint": "/broadcasting/auth",
"clients": [
{
"appId": "xxxxxxx",
"key": "xxxxxxxxxxx"
}
],
"database": "redis",
"databaseConfig": {
"redis": {},
"sqlite": {
"databasePath": "/database/laravel-echo-server.sqlite"
}
},
"devMode": false,
"host": null,
"port": "6001",
"protocol": "http",
"socketio": {},
"sslCertPath": "",
"sslKeyPath": "",
"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"
}
import Echo from "laravel-echo";
window.io = require('socket.io-client');
// Have this in case you stop running your laravel echo server
if (typeof io !== 'undefined') {
window.Echo = new Echo({
broadcaster: 'socket.io',
host: window.location.hostname,
});
}
[program:staging-echo-server]
process_name=%(program_name)s_%(process_num)02d
directory=/var/www/laravel-project-path
command=laravel-echo-server start
autostart=true
autorestart=true
user=www-data
numprocs=1
redirect_stderr=true
stdout_logfile=/var/log/supervisor/laravel-project-staging.log
RewriteEngine On
RewriteCond %{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.io
ProxyPassReverse /socket.io http://localhost:6001/socket.io
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment