Repository: beyondcode/laravel-websockets

Issue #480: Best way to configure laravel websockets + apache + ssl + letsencrypt + supervisor ?
Created: 2020-08-21T22:40:12Z
Hello,
I've succeeded in making websockets work with ssl on apache, but I have some questions on how to configure it "the right way" with let's encrypt.
Let's encrypt update the certificate & private key every 2 months.
By default, the certificate is readable by everyone, but the private key is readable only by root (as it should be).
First question:
- should the websockets service be restarted every 2 months ? (each time the cert & key are regenerated) or does it get the new cert automatically ?
Second question:
- under which linux user should the command "php artisan websockets:serve" be run ? (and be configured in supervisor)
But to answer that question, there is another one before:

can the websockets server write things in the laravel log (even when crashing).
Because since I use daily logs for laravel, if a log file is created by another user than "www-data", the next time that the webapp want to log something, it will crash because it doesn't have permission on the log file.
Other side effects could be any files written by the server (uploaded files, cached views...)
I don't know if the websocket server can have any impact on this, or if it only deals with sockets.

So, the goals are:
1 - best security possible
2 - everything is automated
3 - doesn't have side effects with permissions (log files that make the app crash...)
The easiest way is to choose root, but:
1 - running code from the root user is bad
2 - ok
3 - may cause problems with logs
2nd solution, "www-data":
1 - it's better on security, but not great either... because now the entire web app has access to the private key
2 - it can't read the private key file... so it means we should find a way to change permissions (or to copy it to another place with the correct permissions) on that file each time it's generated
3 - no side effect, since it's the apache user
3rd solution, a dedicated user "laravel-echo" (like in the docs)
1 - it seems to be the most secure way
2 - same problems with the private key file
3 - may cause problems with logs
So, what is the right way ?
Should a script (or hook) be launched each time let's encrypt update ?
Thanks

Duplicate issue #577: Websockets server with WSS only accepts connections as root user
Created: 2020-10-14T11:43:19Z
Hello,
I have a laravel-websocket server running almost flawless, the only problem is that I have a user websockets and if I run the php artisan websockets:serve with that user (that is the account owner) it will not accept connections, if I run as root, everything works as normal. Due security concerns that is not a recomendable practice, so I would like to solve this, follow a screen capture:
[root@apollo code]# su websockets
[websockets@apollo code]$ php artisan websockets:serve
Starting the WebSocket server on port 6001...
^C
---> nothing happened
[websockets@apollo code]$ exit
exit
[root@apollo code]# php artisan websockets:serve
Starting the WebSocket server on port 6001...
New connection opened for app key MyAwesomeApp.
Connection id 857260704.789554657 sending message {"event":"pusher:connection_established","data":"{"socket_id":"857260704.789554657","activity_timeout":30}"}
New connection opened for app key MyAwesomeApp.
Connection id 561022712.426258577 sending message {"event":"pusher:connection_established","data":"{"socket_id":"561022712.426258577","activity_timeout":30}"}
Anyone has ideas how to solve this?
Cheers

Closing comment (2020-10-14T12:24:02Z): Do you run with SSL? It can be related to #480