kolemcrae
By:
kolemcrae

SSL and redirect issues with wordpress wp-admin page

December 23, 2014 3.9k views

So I signed up with cloudflare and got the universal ssl which is great. I let it propogate overnight.

This morning I checked and the ssl version of my site worked somewhat but had some minor issues. I tried a few plugins and found one that fixed the issues.

I then switched wordpress to make the homepage default to the ssl.

The site worked fine.

The wp-admin had an infinite redirect loop. No idea why.

I tried turning off plugins, to no avail.

I tried changing the site back to non https via wp-config. This makes the regular site now load without the https, so thats fine, but wp-admin still doesn't load.

Any thoughts?

The site is http://torontoboozehound.com
ssl is https://torontoboozehound.com

3 comments
  • I am seeing the redirect which does appear to be between http and https. Since your site is behind CloudFlare, your attempts to resolve the issue may not have had an immediate effect due to the caching done by CloudFlare. If you access your droplet directly via the IP address does /wp-admin load properly?

  • It's possible that the caching is an issue, it concerns me that in my haste I messed something up and when the cache updates I'll be in worse trouble.

    With a proxy both http and https work but wp-admin does not.

    I should note I added the following to wp-config:

    define('WPHOME','https://torontoboozehound.com');
    define('WP
    SITEURL','https://torontoboozehound.com');

    which does not seem to do anything.

  • And wp-config does not load when accessed via the ip address. it tries to forward to ssl and probably breaks because I do not have ssl on the server, only via cloudflare.

1 Answer

Hi #DOers

Although it is 3yrs down-hill, yet answering the question might help someone in need henceforth.

I will explain about how to do it on Ubuntu. It will be the same for other Linux distros but just sudo would become yum in case of CentOS and so on, so forth!

So here goes: "remove endless redirect loop on apache web server" :

Redirect loops are created when you have a proxy in front of your server. In the subject case, we have an Apache server (tested on this day while replying).

Now @kolemcrae seems to have removed #CloudFlare from the picture to achieve HTTPS but here is a quick link to small "magic mod" for Apache Web Server.

A simple guide is given below to download, compile & install the mod from source:

First, install dependencies:

sudo apt-get install unzip build-essential apache2-threaded-dev libtool libtool-bin

For Ubuntu 16.04 and above apache2-threaded-dev is now available on apache2-dev. So replace as your case maybe! Moving on..

Next, download the ZIP archive from GIT from below link:

wget https://github.com/gnif/mod_rpaf/archive/stable.zip

It is preferable that you download this ZIP archive in /tmp folder but it is your choice if you like to clean up manually afterwards. Moving on..

Next, unzip the archive and change to extracted directory i.e. mod_rpaf-stable:

```sudo unzip stable.zip

cd mod_rpaf-stable```

Once inside the directory, it's time to compile & install the archive:

```sudo make

sudo make install```

Now, there is an important prompt when "make install" completes. Please follow that with libtool. For this libtool command to work, you need 'libtool-bin' which we have already installed.

Next, let us setup the mod manually as follows:

sudo nano /etc/apache2/mods-available/rpaf.load

The above command will create and open a new file. Copy & Paste following line in this new file:

LoadModule rpaf_module /usr/lib/apache2/modules/mod_rpaf.so

Next, create an Apache mod in mods-available directory:

sudo nano /etc/apache2/mods-available/rpaf.conf

The above command will create & open a new file for editing. Copy & paste following lines in it:

<IfModule mod_rpaf.c>
RPAF_Enable On
RPAF_Header X-Real-Ip
RPAF_ProxyIPs 127.0.0.1
RPAF_SetHostName On
RPAF_SetHTTPS On
RPAF_SetPort On
</IfModule>

Finally, enable this newly created mod and restart Apache Web Server:

```sudo a2enmod rpaf

sudo service apache2 restart```

That's it !!

Reference: This Article STEP-8
Credits: @jesin

Apache and Nginx are popular web servers, and you may find reasons to use both on the same server. This tutorial walks you through setting up web sites on Apache and Nginx and then proxying requests from Nginx on to Apache.
Have another answer? Share your knowledge.