Skip to content

Instantly share code, notes, and snippets.

@lewislarsen
Last active March 26, 2025 19:19
Show Gist options
  • Save lewislarsen/0254178fe301156b721badf158ca5d45 to your computer and use it in GitHub Desktop.
Save lewislarsen/0254178fe301156b721badf158ca5d45 to your computer and use it in GitHub Desktop.
Instructions for how to setup Laravel Reverb in Production.

Reverb Walkthrough

This guide covers configuring Laravel Reverb for production using services like Laravel Forge or Ploi.

1. Configuring Nginx

Add this to your nginx site configuration's 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";
    proxy_pass http://0.0.0.0:8080;
}

Note

  • /app is Reverb's path, not your application path. Don't change it.
  • Port 8080 is Reverb's default listening port. Adjust if running multiple Reverb instances on the same server.

Important

Restart Nginx after making these changes.

2. Updating your .env

Add these configurations to your .env file:

REVERB_APP_ID=your-app-id
REVERB_APP_KEY=set-a-key-here
REVERB_APP_SECRET=set-a-secret
REVERB_HOST=site.com
REVERB_PORT=443
REVERB_SCHEME=https
REVERB_SERVER_HOST=127.0.0.1
REVERB_SERVER_PORT=8080
BROADCAST_CONNECTION=reverb
### DO NOT REMOVE ###
VITE_REVERB_APP_KEY="${REVERB_APP_KEY}"
VITE_REVERB_HOST="${REVERB_HOST}"
VITE_REVERB_PORT="${REVERB_PORT}"
VITE_REVERB_SCHEME="${REVERB_SCHEME}"
# If you remove this, Reverb will break.

Note

  • Set REVERB_HOST to your site URL without HTTP/HTTPS
  • Configure unique app ID, key, and secret
  • Ensure port numbers are consistent with Nginx configuration
  • Set BROADCAST_CONNECTION to reverb
  • Include VITE variables if your app uses VITE

Tip

Clear your application cache after making changes.

3. Spawning Reverb's Server

Create a daemon on your server with this command (adjust the file path):

php /home/ploi/site.com/artisan reverb:start --host=127.0.0.1 --port=8080 --no-interaction

Tip

Add --debug option for more detailed logging.

Caution

Ensure port numbers are consistent throughout all configurations to avoid issues.

This should result in a successful Reverb setup. This code was taken from my production Reverb app on Ploi.

@Ticket-Master
Copy link

On Ploi, it works but just remember to Restart the Nginx.

Thank you for this !

@lewislarsen
Copy link
Author

On Ploi, it works but just remember to Restart the Nginx.

Thank you for this !

Good shout, I have amended the instructions to mention that you should restart nginx. :)

@iamvinny
Copy link

iamvinny commented Jul 17, 2024

To keep Reverb server running even after you close the terminal, you can use the command below

php /home/ploi/site.com/artisan reverb:start --host=127.0.0.1 --port=8080 --no-interaction >/dev/null 2>&1 &

You can also use supervisor for keeping the process alive.

sudo nano /etc/supervisor/conf.d/reverb.conf
[program:reverb]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/laravel/artisan reverb:start --no-interaction
autostart=true
autorestart=false
stopasgroup=true
killasgroup=true
user=root
numprocs=1
minfds=10000
redirect_stderr=true
stdout_logfile=/var/www/laravel/worker.log
stopwaitsecs=3600
sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start "reverb:*"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment