Last active
May 17, 2024 05:45
-
-
Save adityadees/87693d7bc70527f4a50923e1600de5d1 to your computer and use it in GitHub Desktop.
apache reverse proxy laravel echo server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- npm install pm2 -g | |
- pm2 start echo-server.json --name="apps" | |
```echo-server.json | |
{ | |
"name": "apps", | |
"script": "laravel-echo-server", | |
"args": "start" | |
} | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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