Apache Proxy/Reverse

This page intends to explain how to configure ProxyPass and ProxyPassReverse to allow the management of several servers across a private network.

Configuring Apache must be done at the level of the Apache HTTP server, as well as on the device which is hosting the server/database.

On PiPlex for example: modify the file: /etc/apache2/sites-enabled/000-default.conf to insert the following:

#MONEY
<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName money.homeyann.duckdns.org
        ProxyPreserveHost On
        ProxyPass / http://192.168.86.160:80/
        ProxyPassReverse / http://192.168.86.160:80/
        ProxyRequests On
</VirtualHost>

#SESAME
<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName sesame.homeyann.duckdns.org
        ProxyPreserveHost On
        ProxyPass /  http://192.168.86.160/
        ProxyPassReverse /  http://192.168.86.160/
        ProxyRequests On
</VirtualHost>

#ERWAN
<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName erwan.homeyann.duckdns.org
        ProxyPreserveHost On
        ProxyPass /  http://192.168.86.160/
        ProxyPassReverse /  http://192.168.86.160/
        ProxyRequests On
</VirtualHost>

#WATCHES
<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName watches.homeyann.duckdns.org
        ProxyPreserveHost On
        ProxyPass /  http://192.168.86.160/
        ProxyPassReverse /  http://192.168.86.160/
        ProxyRequests On
</VirtualHost>

Run the following command after saving the file:

systemctl restart apache2.service

Note: The ‘slash’ character at the end of the back-end server IP address is mandatory so as to be able to access/serve all sub-directories.

On each back-end server, modify the file /etc/apache2/sites-enabled/000-default.conf by inserting the following (here is the example for all databases hosted on PiDatabase):

#MONEY
<VirtualHost *:80>
        ServerName money.homeyann.duckdns.org
        DocumentRoot /var/www/MONEY/
</VirtualHost>

#SESAME
<VirtualHost *:80>
        ServerName sesame.homeyann.duckdns.org
        DocumentRoot /var/www/SESAME/
</VirtualHost>

#ERWAN
<VirtualHost *:80>
        ServerName erwan.homeyann.duckdns.org
        DocumentRoot /var/www/ERWAN/
</VirtualHost>

#CARS
<VirtualHost *:80>
        ServerName cars.homeyann.duckdns.org
        DocumentRoot /var/www/CARS/
</VirtualHost>

Note: There is no evidence that the ‘slash’ character is mandatory but it does not cost a dim to add it. Omitting the ‘slash’ character provides the same result.

Run the following command after saving the file:

systemctl restart apache2.service