How to improve SEO potential by installing WordPress using a Reverse Proxy

Adam Sapic Profile Pic
By Adam Šapić

I would like to send a big thanks to Nick Wilsdon for inspiring this article.

Here’s the scenario. The server that hosts your main website cannot support WordPress but you want to use it as your blogging platform. What do you do? A common option is to install WordPress using a subdomain linked to your root domain. However, many SEO influencers contest this in favour of placing link worthy content in a subfolder. A solution to overcome this challenge is called a reverse proxy.

In this article, I explain what a reverse proxy is, the reasons why you may wish to use it and a method of implementation including key pointers.

What is a reverse proxy?

A reverse proxy is a type of proxy server that returns responses to the client from multiple origin servers. For example, your information request using a website is sent to a reverse proxy server. It is then directed to the actual server where the info is stored before being returned to you via the reverse proxy. The info is returned as if it originated from the original server itself. 

Reverse Proxy Diagram Explanation

Why use a reverse proxy to install WordPress?

Using a reverse proxy is an option if you want to avoid installing WordPress on your web server that hosts your main website. For example, insurance companies use bespoke real-time quoting engines. They may prefer to create such software in .NET for reasons related to scalability or avoiding open source systems. Therefore, the mission-critical solutions run by the quoting engines rules out the option of installing third-party components such as WordPress on the server.

But you really want to use WordPress as your blogging platform due to its robust content management system (CMS). So how do you get around this problem? A common solution is to install WordPress using a subdomain and create appropriate links with your root domain. However, this option could affect your SEO.

Subdomains are essentially their own separate entity within your root domain such as mybusiness.com. Search Engine Journal explains this in more detail. They advise you use a subdomain if you intentionally want to separate your content within your overall website. For example, you have multiple translations like Wikipedia:

https://en.wikipedia.org/

https://fr.wikipedia.org/

https://es.wikipedia.org/

Or you have content that is relevant for certain locations such as Craigslist:

https://bristol.craigslist.co.uk/

https://birmingham.craigslist.co.uk/

https://london.craigslist.co.uk/

Looking at these examples, using subdomains makes sense. So why could this impact your SEO when using a subdomain for a blog? According to Google, there is no right or wrong answer.

Google has confirmed that search looks at both subdomains and subfolders equally. SEO influencers such as Moz contest this. The counter-argument uses evidence from independent tests. Many have repeatedly concluded using a subdomain for a blog does not give the maximum ranking potential. Others disagree and back up Google’s statement.

It’s important to note Google does explain that separate tracking and indexing is required per subdomain. Therefore, those who are in favour of installing blogs via subfolders argue it’s easier to maintain. Google also advise you choose a structure that will suit your long-term digital plan because you should avoid changing link structures if possible.

Google advises you choose a website structure that will suit your long-term digital plan because you should avoid changing link structures if possible. Click To Tweet

I’ll leave it up to you to decide what is the best option. However, if you want to use a subfolder but cannot install WordPress on your server, a reverse proxy is a viable solution. Here’s how to do it.

—DISCLAIMER—

This is considered an advanced procedure. If your internal team do not have any experience creating a reverse proxy, I would highly recommend you employ a suitable professional such as a systems architect.

The following info is a guideline, therefore, UNIMETRICS in no way can be held responsible for any unwanted results.

Backup!

Before you begin, if your blog already exists, double check that it is backed up or you have the ability to rollback just in case.

How to create a reverse proxy

You’ll firstly require a hosting provider who supports reverse proxies. The first step is to check with your current provider. I found out that providers like Siteground and names.co.uk do not support reverse proxies.

You will need a Virtual Private Server (VPS) or dedicated server where you have control over the file system structure and layout as well as the option to create virtual hosts via apache.

If your origin server runs Apache this is a well-understood procedure; you enable mod proxy on the origin server and then add a stanza similar to:

<Location /blog>
ProxyPass http://blog.mysite.com 
ProxyPassReverse http://blog.mysite.com  
Order allow,deny   
Allow from all
</Location>

However, in the scenario we have described, your origin server is almost certainly running Windows IIS so you will require an IIS Application Routing Request.  Do this by placing a web.config file in the blog folder similar to this:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                    <match url="(.*)" />
                    <action type="Rewrite" url="https://linode.mybusiness.com/{R:1}" />
                </rule>
            </rules>
            <outboundRules>
                <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
                    <match filterByTags="A, Form, Img" pattern="^http(s)?://linode.mybusiness.com/(.*)" />
                    <action type="Rewrite" value="http{R:1}://www.mybusiness.com/{R:2}" />
                </rule>
                <preConditions>
                    <preCondition name="ResponseIsHtml1">
                        <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                    </preCondition>
                </preConditions>
            </outboundRules>
        </rewrite>
    </system.webServer>
</configuration>

Make sure that an SSL certificate is issued to your WordPress hosting server, and that the DNS name matches the proxy configuration.

If you get an invalid response from the proxy server, another option to consider is routing all content to the proxy server which then uses a ProxyPass back to the IIS server apart from the blog subfolder which will sit on your root domain such as mybusiness.com/blog. This approach might not be the best solution if you don’t want to mess around with your IIS server because it hosts critical websites.

Either way, lab up a replica of the server that hosts your main website for troubleshooting. Check the web.config of your main website and the blog folder.

WordPress admin in particular isn’t really designed to sit behind a reverse proxy. Make sure that your wp-config.php contains the following line:

$_SERVER['REQUEST_URI'] = str_replace("/wp-admin/", "/blog/wp-admin/", $_SERVER['REQUEST_URI']);

and that WP_HOME and WP_SITEURL are correctly reflecting the location of /blog/

Create a symbolic link in the WordPress document root: ln -s . blog

Modify .htaccess so that

RewriteRule . /index.php [L] 

becomes

RewriteRule . /blog/index.php [L]

If you see the following error message, the easiest solution is to disable mod deflate on your Apache WordPress server.

HTTP Error 500.52 – URL Rewrite Module Error.

Outbound rewrite rules cannot be applied when the content of the HTTP response is encoded (“gzip”).

This process assumes your WordPress site is already running under SSL and you don’t have any mixed content or re-direct loop challenges.

Updating WordPress

After completing this, you need to ensure that all URLs such as category and post pages are displaying correctly.

Simply log in using the original link, for example, if you were using a subdomain, it would be:

blog.mybusiness.com/wp-login.php

Go to ‘Settings’ then ‘General’ and update the ‘Site Address (URL)’ field with your new subfolder. 

Update wordpress site URL after a reverse proxy

A plugin called Better Search Replace is a handy tool to make sure that everything in your database was correctly updated.

Also be aware of updating your canonicals and robots.txt as well as implementing any required redirects.

Troubleshooting Plugins

After the installation is complete, you may notice errors when using WordPress such as editing articles or categories. This is most likely due to certain plugins not coping with the reverse proxy.

If you are experiencing this, deactivate all plugins and then reactivate one-by-one to identify those that are causing problems. After this, your options are finding an alternative plugin that works with a reverse proxy or contact your existing plugin developers for support.

You also may wish to consider whether you really need the plugins that are causing problems and simply delete them.

If certain plugins are crucial to your WordPress blog, then contact the plugin developers before you decide to use a reverse proxy so you can weigh up your options.

Concluding thoughts

Three months ago our team migrated our client’s WordPress blog from a subdomain to a subfolder using a reverse proxy. When comparing the last three months with the previous three months, it’s pleasing to see an increase in the number of acquisitions from organic search.

Increase in organic search traffic following a reverse proxy on wordpress

Obviously there are other factors to take into consideration when drawing conclusions. However, the total amount of organic search traffic detailed above is still 19.20% higher compared with the total amount at the last quarterly increase. I can deduce that the reverse proxy has contributed to the overall proportionate growth of organic search acquisitions since the start of 2018.

If you still need help with this, contact us today for a chat.

Adam Sapic Profile Pic

Adam Šapić

Adam is the digital marketing strategist at UNIMETRICS. He is a website and data devotee, writer, designer, creator, strategic thinker and doer. He loves to discuss, learn & share.

By signing up you are agreeing to our Privacy Policy.