Laravel reverb Config

After setting up reverb to be running on your vps, there are few changes you need to make all your server route websocket request to your laravel reverb.

🔧 NGINX Configuration

To proxy WebSocket requests to Laravel Reverb via Nginx, you must edit your virtual host (vhost) file or Nginx site configuration.

Add the following location block inside your server block:

location /app {
    proxy_http_version 1.1;
    proxy_set_header Host $http_host;
    proxy_set_header Scheme $scheme;
    proxy_set_header SERVER_PORT $server_port;
    proxy_set_header REMOTE_ADDR $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
    
    # CORS headers for WebSocket
    add_header Access-Control-Allow-Origin *; # Or specify your domain
    add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
    add_header Access-Control-Allow-Headers 'Origin, Content-Type, Accept, X-Requested-With';
    
    proxy_pass http://127.0.0.1:6001;
}

⚠️ Important

Make sure the IP address and port in proxy_pass match the Reverb server port defined in your .env file:

If you change these values in .env, you must also update the Nginx configuration to reflect the new host and port.

After editing the config:

🔧 Apache Configuration

If you are using Apache, ensure the following is added to your virtual host configuration:

⚠️ Important

As with Nginx, you must ensure that the port (6001) align with:

Apply changes and restart Apache:

.ENV Configuration

Here is the expected reverb configuration in your .env. If file differs, please update your .env with values in the below code:

Last updated

Was this helpful?