How to Get Free SSL for Laravel
Free SSL for Laravel is set up in two halves. First the certificate on the web server or in front of it. Then the application options, so URLs, redirects and cookies all use https. Skipping the second half is why many Laravel sites show a padlock and still emit http links from queues and forms.
Step 1: issue a free SSL certificate for Laravel
On a VPS running Nginx, use Certbot. Your domain must already point at the server:
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d example.com -d www.example.com
sudo certbot renew --dry-run
Managed tools such as Laravel Forge can issue certificates for you through their interface. Check their current docs. For managed hosts like those in Railway, Render and Fly.io, the platform attaches a certificate to your custom domain.
Step 2: Point Nginx at the public folder
Make sure the server root is the public directory, not the project root. That keeps .env out of reach. Nginx redirect for port 80:
server {
listen 80;
server_name example.com www.example.com;
return 301 https://example.com$request_uri;
}
Step 3: Set APP_URL
In .env set the https address:
APP_URL=https://example.com
Then clear cached configuration so the new value is used:
php artisan config:clear
php artisan cache:clear
Step 4: force https so free SSL for Laravel is used everywhere
If the app still generates http links, force the scheme in your AppServiceProvider boot method, only for production:
use Illuminate\Support\Facades\URL;
if (app()->environment('production')) {
URL::forceScheme('https');
}
Step 5: Trust the proxy
Behind a load balancer or CDN, Laravel only sees http unless it trusts the forwarded headers. Configure trusted proxies for your version. In recent releases this is done in the application bootstrap file, in older ones in the TrustProxies middleware. Use your real proxy addresses rather than a wildcard where you can. Our reverse proxy SSL guide explains the headers involved.
| Symptom | Likely cause | Fix |
|---|---|---|
| Links generated with http | Proxy not trusted or APP_URL wrong | Trust proxies, fix APP_URL |
| Redirect loop | Proxy sends http to origin | Pass X-Forwarded-Proto |
| Session cookie not set | Secure cookie over http | Check SESSION_SECURE_COOKIE |
| Mixed content from assets | Hard-coded http in Blade | Use the asset helper |
Step 6: Secure cookies
Once the site is fully https, set SESSION_SECURE_COOKIE=true in .env so session cookies are only sent over https. Test login before and after.
Step 7: Local development
For local work, tools like Laravel Herd or Valet can serve a development site over https with a local certificate. That is separate from the production certificate and is not trusted by the public.
Step 8: Verify
- Run
curl -I http://example.comand check for a 301. - Check forms, login and API calls for mixed content.
- Run the SSL checker.
- Review headers in the security headers guide.
Queue workers and generated URLs
Background jobs and scheduled commands run without a web request, so Laravel cannot guess the scheme and uses APP_URL instead. That is why emails sent from a queue sometimes contain http links when the page itself is https. Setting APP_URL correctly and clearing the configuration cache fixes it. Restart queue workers after changing .env, because they keep the old configuration in memory.
php artisan queue:restart
Quick questions
Should I use a wildcard for trusted proxies?
Only if you cannot list your proxy addresses. A specific list is safer, because a wildcard trusts forwarded headers from anywhere.
Does Laravel need a restart after changing APP_URL?
Clear the config cache, and restart queue workers and any long-running process such as Octane.
Can I use a free certificate with an API?
Yes. API clients validate the certificate in the same way as browsers, so make sure the full chain is served. Test it with the key pair matcher guide if a client reports a chain or key error.
What about Docker deployments?
Keep the certificate and renewal on the proxy container or the host, and let Laravel see plain http behind it with trusted forwarded headers.
Related reading: free SSL on Cloudways and free SSL on Google Cloud.
Frequently Asked Questions
Should I use a wildcard for trusted proxies?
Only if you cannot list your proxy addresses. A specific list is safer, because a wildcard trusts forwarded headers from anywhere.
Does Laravel need a restart after changing APP_URL?
Clear the config cache, and restart queue workers and any long-running process such as Octane.
Can I use a free certificate with an API?
Yes. API clients validate the certificate the same way browsers do, so serve the full chain and test from a client that is not your browser.
What about Docker deployments?
Keep the certificate and renewal on the proxy container or the host, and let Laravel see plain http behind it with trusted forwarded headers.
Why do queued emails still contain http links?
Background jobs have no request to read the scheme from, so they fall back to APP_URL. Set it to the https address, clear the config cache and restart the workers.
✅ Post-Installation Verification & SEO Checklist
After applying the steps above, run through this 5-point checklist to prevent browser warnings and protect your Google SEO rankings:
- Verify full CA chain trust and TLS 1.3 support using our Live SSL Checker.
- Scan for Mixed Content HTTP links and check HSTS/CSP headers on Security Headers Checker.
- Enforce a permanent 301 HTTP-to-HTTPS redirect with our HTTPS Redirect Generator.
- Confirm both root and
wwwversions resolve cleanly to one canonical HTTPS URL. - Verify your HTTPS property and
sitemap.xmlinside Google Search Console and Bing Webmaster Tools.