How to Configure WebSockets in DirectAdmin

ish

Verified User
Joined
Nov 27, 2021
Messages
7
Hi,
I'm developing a real-time chat app using the Laravel framework. when I'm developing the chat application, I used the Laravel WebSocket package. it's working perfectly in localhost. but, when I deployed it to the direct admin c panel by running WebSocket with the command 'php artisan websocket:serve', it was not working as in the localhost. could I know please, how to configure the Laraval WebSocket app in the DirectAdmin ?. also, it's a pleasure if I could know how to put the NGINX CONFIGURATION into the WebSocket of the DirectAdmin. waiting for a reply as soon as possible. thank you for your time.

Documentation of the Laravel WebSockets

Thank you
 
Hey!

I used this configuration to connect to a websocket server through the nginx reverse proxy. You can try.

try:


Add the following to the very top of the file:
Code:
map $http_upgrade $type {
  default "web";
  websocket "ws";
}

Add the following inside of your SSL server block:
Code:
    location / {
        try_files /nonexistent @$type;
    }

    location @ws {
        proxy_pass             http://127.0.0.1:6001; #Change the wss port
        proxy_set_header Host  $host;
        proxy_read_timeout     60;
        proxy_connect_timeout  60;
        proxy_redirect         off;

        # Allow the use of websockets
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
You can now save and close this file. These configurations will tell Nginx about your websocket server, and how to send requests to it.
 
Hello
I'm using apache server, in apache server how can i run "php artisan websocket:init" command?
 
Back
Top