Setup beyondcode/laravel-websockets with Laravel forge
Max Hutschenreiter -
Laravel-websockets package by beyondcode brings the power of WebSockets to your Laravel application. It’s a great free pusher replacement and it offers SSL and Laravel Echo support.
It’s really easy to set it up and replace pusher on your local project.
When I tried to implement it into a live project driven by Laravel forge, it was not a perfectly easy cause of Laravel forge limitations so I will share a workaround on that.
Laravel forge doesn’t allow you to add multiple server blocks within one site so it’s not possible to add another server directive that runs on a different port (6001 by default), so we will create another site with another Laravel instance and proxy pass from 443 to port 6001 on that instance.
The first thing to do is to extend .env file on live project that will work as sockets client:
So by the end of the process, you should have two separate sites. Both of them have beyondcode/laravel-websockets package integrated, but one acts as a client (main application) and one acts as a sockets server (sockets.domain.com).
Env pusher secret details need to be the same for both and that’s it.