I've been using Laravel Sail since it launched and have loved the simple, Docker-based approach to running Laravel on my local machine. However, recently I ran across the issue that Laravel Sail doesn't support HTTPS (SSL). Under the hood Sail uses the `php artisan serve` command to serve web pages instead of using a full blown web server such as Nginx or Apache. This is a neat trick to keep things simple and lightweight but it's not great if you're working on a project that requires some features that a full web server might offer (such as HTTPS).
As Laravel Sail is basically just a thin wrapper around Docker, customising it is pretty simple. My solution to this problem was to use Caddy as a reverse proxy to the Laravel Sail container. Caddy is great for this as it's very easy to configure and offers a great automatic HTTPS feature. To get this working I needed to make a couple of small changes to my config:
The full source code changes can be seen in this gist.
The final step is to trust the Caddy root certificate so you don't constantly get warnings about the local certificates being invalid. This can be done by:
If you've followed these steps you should now have wildcard, automatic HTTPS running on your Laravel Sail project!