How to Get Free SSL for Drupal
Drupal leaves transport security to the web server. That means the certificate and the redirect live outside Drupal, and settings.php handles a few details such as proxies and trusted host names. The steps below follow that split.
Step 1: Get a certificate
On managed Drupal hosting the certificate is often automatic. On your own server or a VPS, use an ACME client such as Certbot:
sudo certbot --nginx -d example.com -d www.example.com
sudo certbot renew --dry-run
On shared hosting use the panel option, described in getting free SSL on shared hosting. Verify with the SSL checker.
Free SSL for Drupal, step 2: redirect http to https
Drupal's own .htaccess includes a commented section for an https redirect on many versions. Check your file, since it differs between releases. If it is missing, add a rule yourself:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
On Nginx use a port 80 server block that returns a 301 to the https name. Do the redirect once, at the server, not inside Drupal.
Free SSL for Drupal, step 3: trusted host patterns
Drupal 8 and later can limit which host names it answers to. If you have set this, make sure the https names are covered:
$settings['trusted_host_patterns'] = [
'^example\.com$',
'^www\.example\.com$',
];
Wrong patterns cause a "provided host name is not valid" error, so test after saving.
Step 4: Behind a load balancer or proxy
When TLS is ended before Drupal, tell it to trust the proxy so that it generates https links and sets secure cookies:
$settings['reverse_proxy'] = TRUE;
$settings['reverse_proxy_addresses'] = ['10.0.0.5'];
Use the real address of your proxy. See the reverse proxy SSL guide for how the forwarded headers should look.
Step 5: Clear caches and rebuild
Run a cache rebuild so generated URLs update:
drush cache:rebuild
Without Drush, use the performance page under Configuration in the admin menu.
Step 6: Fix mixed content
| Source | Where to fix |
|---|---|
| Body text with http images | Edit the content or run a database update |
| Theme templates | Change hard-coded links in Twig files |
| Block content and menus | Edit the block or link |
| Contributed modules | Update the module or its settings |
Check the Console on several page types. The general method in our mixed content guide applies even though it is written for WordPress.
Step 7: Verify
- Request the http address with curl and check for a single 301.
- Log in and confirm the session cookie is marked secure.
- Run the checker and read the expiry date.
- Test file uploads and forms.
When it all works, review security headers with the security headers guide and consider HSTS.
Modules and the database
Some contributed modules store absolute http URLs in configuration or content. After the switch, export your configuration and search it for old addresses. Content fields with filtered text can hold http links too. Fix them in the editor, or write an update script if there are many. Take a database backup before any bulk change.
Checks for editors
- Embedded media uses https sources.
- Menu links to the site itself are relative or https.
- Webform and other module endpoints use https.
- Cron and external callbacks use the https address.
Related reading: free SSL for WooCommerce, free SSL for OpenCart, migrating a site to HTTPS and fixing HTTPS canonical URL issues.
Frequently Asked Questions
Do I need a Drupal module for https?
Not on current versions. The redirect and certificate are handled by the server. Old Drupal 7 sites used a Secure Pages style module, which is not needed once the server redirects.
Why do I get a host name error after the change?
The trusted host patterns list probably lacks one of your names. Add the root and www forms.
How do I check that cookies are secure?
Log in over https and open the browser developer tools. In the storage view, the session cookie should show the secure flag. If it does not, the request was seen as http, and the proxy settings above need another look.
What about multisite installs?
Each site folder has its own settings.php, so repeat the trusted host and proxy settings in each one.
Does Drupal need a module for HTTPS?
No. The web server terminates TLS and Drupal reads the request. A module only helps when you want to force the scheme inside Drupal rather than at the server.
Why does Drupal redirect back to http?
The base URL in settings.php still starts with http, or a reverse proxy is not trusted so Drupal cannot see that the request arrived over HTTPS.
✅ 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.