Getting Dokku, WordPress and Let’s Encrypt SSL Working


If you’re reading this, you’re probably trying to get WordPress running on Dokku. Hopefully you have already figured out how to setup/connect MySQL. Once you have that, your WordPress site should be accessible (over http). But then you’ll probably want to have your site accessible over https because Google is now ranking secure sites higher and even Google Chrome is warning if sites aren’t transmitting over SSL. So, you probably found the Let’s Encrypt plugin for Dokku and installed an SSL certificate. And this is probably where you hit and problem that led to a Google search and led you here. Your site will automatically redirect from to but you’ll get mixed content warning because the site is trying to load external assets over http instead of https. You probably also get stuck in a infinite redirect loop (ERR_TOO_MANY_REDIRECTS) when trying to login to the admin panel. I did a lot of researching and couldn’t find a solution but eventually found someone who had figured out what was causing this problem. The easy explanation is that WordPress didn’t realize it was being requested over SSL and therefore didn’t load its assets over SSL. To fix this, you just need to add the following to your wp-config.php file:

    $_SERVER['HTTPS'] = 'on';

This basically detects if the request is going over SSL and sets the HTTPS server variable to on so that WordPress will treat the request as a secure request. This is due to the fact that we’re using nginx which was causing WordPress to think the request was a non-secure request. I hope this helps someone. Happy hacking.