Today at job I was working on a site where i had to implement SSL to make it secure. Normally, it would have been no hassle since the certificate was already installed and all i had to do was to port the site to use it.
But did I tell you the site was made using WordPress? Well, say what you want but despite being the most famous CMS software, it’s a tricky job to port an existing WordPress site to SSL. That is, if you are using the SSL as a reverse proxy.
So at the beginning, i thought it’s a simple job where i will only have to replace the base URL and the rest will be taken care of. And i changed the options table to reflect those changes. What happened after was what made me write about it.
I went to the home page and it would just not show anything and end in an error just like the one in the title. I thought maybe I can fix it in the admin panel and tried the good old wp-admin url, but that also didn’t work.
Still, i kept my head down and kept at it thinking I must have made a mistake. After a few hours and some solemn vows to never take up another WordPress project without resistance, I decided to give the virtual host files one last go and I noticed that the SSL certificate settings were nowhere to be found on my current server running Apache.
That raised some suspicions and I decided to talk to the guy who installed those certificates. He told me that the certificates were installed on an Nginx server which was relaying the calls to Apache. I don’t know about you but that felt like pearls of wisdom to me at that moment which led me to my solution involving setting the
HTTPS server flag explicitly like below:
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
Those two magical lines made it work right away.
The rest of the article outlining the need to do so is here: https://codex.wordpress.org/Administration_Over_SSL#Using_a_Reverse_Proxy
I hope that helped!
Latest posts by alexey (see all)
- Zend Soap NULL Reponse - August 29, 2018
- Quick Facts About WooCommerce - April 25, 2018
- WordPress stuck on a “Too many redirects” error loop when using SSL - January 17, 2018