Apache Reverse Proxy for Moodle on CentOS 7.3

The Musing

As I’ve written previously, we moved our Moodle server to a virtual server, but I also keep live backups of each term for as long as possible. Because we’ve been using Moodle for almost ten (10) years, we have mountains of data, and it won’t all fit on the virtual machine. I’d still like to keep it live, not just on backup disk/dvd/whatever.

The Situation

I still have the previously used physical server that ran Moodle. It has tons of storage available, and still runs well, but it’s no longer under warranty which is one reason we moved our production Moodle instance to a VM. I want the physical machine to host the files/DB for all of the old Moodle installs, but so all of the URLs remain the same, use the VM as a frontend and reverse proxy (both http and https) to serve content from the physical machine.

The Fix

Essentially, I have to modify the VirtualHost entries for both http (80) and https (443).

<Location /2017Summer> 
ProxyPass http://moodleoldIP/2017Summer 
ProxyPassReverse http://moodleoldIP/2017Summer 
ProxyPreserveHost On 
Require all granted 
</Location>

and in ssl.conf:

SSLProxyEngine On
<Location /2017Summer>
ProxyPass https://moodleoldIP/2017Summer
ProxyPassReverse https://moodleoldIP/2017Summer
ProxyPreserveHost On
Require all granted
</Location>

Now, do a systemctl reload httpd and everything seems to work!

Leave a Reply