How to setup HTTPS with Laravel Homestead on a Windows host
Nikolas Evers Oct 16 Originally published at nikol.as on Oct 16, 2018
This guide assumes prior experience with Vagrant and Laravel Homestead.
Laravel Homestead is an easy-to-use Vagrant box for local Laravel development, but getting SSL to work on a Windows host can be tricky if you've never done it before. This guide will show you how to enable SSL and how to trust the certificate in Firefox.
Let's create a new Laravel project for demonstration purposes:
composer create-project --prefer-dist laravel/laravel ssl-example
Now we need to configure a Homestead instance for our project:
cd ssl-example composer require laravel/homestead --dev vendor\\bin\\homestead make
You should see the following output in your console:
Homestead.yaml and make the following changes:
- map: homestead.test + map: laravel.localhost to: /home/vagrant/code/public + ssl: true
Note: Feel free to change
laravel.localhostthroughout the guide to a local domain of your choice.
Homestead.yaml should now look similar to this:
ip: 192.168.10.10 memory: 2048 cpus: 1 provider: virtualbox authorize: ~/.ssh/id_rsa.pub keys: - ~/.ssh/id_rsa folders: - map: 'D:\Documents\GitHub\ssl-example' to: /home/vagrant/code sites: - map: laravel.localhost to: /home/vagrant/code/public databases: - homestead name: ssl-example hostname: ssl-example ssl: true
Add the following line to
Note: The IP address should match
Install the Homestead Vagrant Box:
vagrant box add laravel/homestead
Let's start our Vagrant box:
If you are using this guide to add SSL to an existing VM, use this command instead:
vagrant reload --provision
Wait until the provisioning process has been completed.
You should now be able to visit http://laravel.localhost in your browser:
Now we need to get the CA certificate from the VM:
vagrant ssh -c 'cat /etc/nginx/ssl/ca.homestead.ssl-example.crt' > ca.homestead.ssl-example.crt
ssl-exampleto match your
You should now have
ca.homestead.ssl-example.crt inside your
In Powershell, as admin, run the following command to add the certificate to the certificate store:
certutil -addstore -enterprise -f "Root" ca.homestead.ssl-example.crt
Note: You can now remove
Last but not least, we need to get Firefox to trust the certificate.
In Firefox, navigate to
about:config. Read this introduction if your unfamiliar with the Configuration Editor for Firefox.
true and restart Firefox.
You should now be able to visit https://laravel.localhost in your browser.
I’ve sent a message to my family and delegated my open source projects to my friends. With my last tweet sent, I turn off my laptop, phone, and tablet. My Digital Sabbath begins in 10 minutes: no digital devices for the next month.