Skip to content

Instantly share code, notes, and snippets.

@maxkostinevich
Forked from conradfuhrman/herd-reverb-ssl.md
Created April 15, 2024 15:08
Show Gist options
  • Save maxkostinevich/97c9e14f9b4ab8076582de9912e6524d to your computer and use it in GitHub Desktop.
Save maxkostinevich/97c9e14f9b4ab8076582de9912e6524d to your computer and use it in GitHub Desktop.
Laravel Herd, SSL, and Reverb with Herd

The biggest issue with Herd Pro is that you cannot use Reverb out of the box with a site that has SSL enabled. Here is the workaround for it all to play nicely together.

First you will need to create two sites. The two I have here are as follows:

  • reverb-ssl - This is a new Laravel 11 project using Breeze for the ease of Inertia. This also follows the setup for Reverb line by line.
  • wss-reverb-ssl - This is an empty directory, we are going to use this only for editing a Nginx config and setting up a proxy to the reverb service.

Screenshot 2024-04-03 at 2 33 08 PM

Of note is that I'm using Herd Pro as well, so all additional services are being used directly though Herd Pro itself.

Onec those two sites have their SSL's as provisioned by Herd, we'll now fire up the Reverb Service. You can see I'm running both MySQL and Reverb as my Services and both are active.

Screenshot 2024-04-03 at 2 36 17 PM

Once this is running copy the enviroment variables and we'll adjust our Laravel Project which is the reverb-ssl directory.

The updated .env variables should now be:

APP_URL=https://reverb-ssl.test

REVERB_APP_ID=1001
REVERB_APP_KEY=laravel-herd
REVERB_APP_SECRET=secret
REVERB_HOST="wss-reverb-ssl.test"
REVERB_PORT=443
REVERB_SCHEME=https

Notice that they match the app ID, and that the nost matches that additional directory that we setup and added an SSL to. This is very important as this Host is where we are going to now edit an Nginx conf file and setup our proxy.

In your ~/Library/Application Support/Herd/config/valet/Nginx/ directory, there will be a wss-reverb-ssl.test file. Open that and you'll find a faily standard Nginx config file. We're going to replace a few lines.

You'll want to find these lines:

location / {
    rewrite ^ "/Applications/Herd.app/Contents/Resources/valet/server.php" last;
}

And replace those lines with these:

location / {
        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";

        # This is for Mac
        proxy_pass http://0.0.0.0:8080;
        
        # This is for Windows
        proxy_pass http://localhost:8080;
}

Once this is saved, stop and restart the general Herd services (Nginx, PHP, DNSMasq) and you should be all set. Visting reverb-ssl.test will now have the ability to listen to Reverb via Echo!

Screenshot 2024-04-03 at 2 52 15 PM

@jeremynikolic
Copy link

Thanks a lot, this helped me figure this out 🎉

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