Use SSL on Laravel Homestead

Stefan Bogdanescu

Founder & Senior Architect · 2026-06-29

Laravel Company

Mastering HTTPS on Laravel Homestead: From Certificates to Live Site

As a senior developer working with local environments like Laravel Homestead, setting up secure HTTPS access can sometimes feel like an extra layer of complexity. You’ve correctly identified the first steps—adding ssl: true to your homestead.yaml and running vagrant reload --provision successfully generates the necessary SSL certificates (.crt, .key, and .cnf).

However, generating these files is only half the battle. The real challenge lies in configuring your web server (typically Nginx within Homestead) to actually use those certificates to serve traffic over HTTPS, and ensuring everything redirects correctly. This guide will walk you through the crucial next steps to transition from having certificate files to running a fully secure, live site on Laravel Homestead.

Phase 1: Validating the Certificate Generation

Before moving on, let's confirm what we have. When you run the provisioning script with ssl: true, Homestead provisions Nginx with SSL setup routines, which create these files in /etc/nginx/ssl:

laravel-cashier.local.cnf
laravel-cashier.local.crt
laravel-cashier.local.key

These files are the foundation of your SSL implementation. They tell the web server (Nginx) what certificate and private key to use for encryption. The next step is telling Nginx how to use them.

Phase 2: Configuring Nginx for HTTPS Redirection

Since Homestead typically uses Nginx as the web server, we need to edit the Nginx site configuration file to enforce SSL. This process ensures that all HTTP requests are redirected to HTTPS and that the server is listening on port 443 securely.

  1. Locate the Configuration: Navigate to your virtual machine via SSH and find your Nginx configuration file. For Homestead setups, this is often located within the VM or a specific site configuration directory.
  2. Modify Server Blocks: You need to adjust the server block for your application (e.g., laravel-cashier.local) to listen on port 443 and use the certificate files you just created.

A typical Nginx configuration snippet for enforcing SSL looks like this:

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    server_name laravel-cashier.local;

    # Point to the generated certificate and key files
    ssl_certificate /etc/nginx/ssl/laravel-cashier.local.crt;
    ssl_certificate_key /etc/nginx/ssl/laravel-cashier.local.key;

    # Recommended SSL settings for security
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers on;

    # ... rest of your location/root directives
}

# Optional: Redirect HTTP (port 80) to HTTPS (port 443)
server {
    listen 80;
    listen [::]:80;
    server_name laravel-cashier.local;
    return 301 https://$host$request_uri;
}

By implementing this configuration, you are telling Nginx: "When a user tries to access me via HTTP (port 80), immediately redirect them to the secure HTTPS connection (port 443) using these specific certificates." This setup is critical for security and proper web traffic flow.

Phase 3: Testing and Finalizing Access

After modifying your configuration files, always test the syntax before reloading the service:

sudo nginx -t
sudo systemctl reload nginx

Finally, access your site using https://laravel-cashier.local. If configured correctly, you should see a padlock icon, confirming that the connection is encrypted.

Conclusion

Implementing SSL on Laravel Homestead requires moving beyond simply generating files; it demands proper integration with your web server configuration. The process involves three core stages: certificate generation (which you’ve mastered), Nginx configuration to bind to the new ports and use those certificates, and setting up HTTP-to-HTTPS redirection. By following these steps, you ensure that your local development environment securely mirrors production standards, providing a robust foundation for building applications on Laravel and aligns perfectly with best practices promoted by the Laravel ecosystem at https://laravelcompany.com.