Reverse Proxy made simple (as possible)

Many have written a tutorial on how to host multiple web servers on just one public facing IP address. I went through a number of them, pulling out the understandable stuff from each one, and when I finally got a grasp on how to do it, I decided to write my own tutorial on what it takes, and how to step by step, get it set up. The way it works is, if you have only one public IP address, you can put a number of web servers on it (multiple hosts). If you want to use only one host, you can put multiple domains on just one host. Either way, the receiving host directs traffic internally (in case of a single host solution) or to multiple differfent boxes on the same LAN if each domain will be hosted by one box. In both cases, the domain registrar will need A records set up for all domains to point to your publec IP address.

Let’s put abc.com on a box with internal IP address set to 192.168.1.10
Let’s put xyz.com on a different box with IP address set to 192.168.1.11
We’ll put the proxy server on an apache server with IP address 192.168.1.5

Let’s assume 123.123.123.123 is your public IP address. You’ll need to set Port Forwarding on your router so that any traffic coming into 123.123.123.123 on TCP port 80 or 443 gets forwarded to the internal IP of 192.168.1.5 (The proxy server).

I use Apache on top of Linux as both the proxy server, and individual hosts. We will use Apache.We will use two domain names, abc.com and xyz.com.

Make sure you configure the settings in your registrar’s A records to always point abc.com and xyz.com to Public IP address 123.123.123.123.

We’ll assume both web host boxes are set to properly display their web pages if you
enter their IP address in a web browser. They will respond on port 80 as you do not
configure https on any of the local hosts. The https encryption is all done on the
proxy server.

Lets make sure forwarding works first:
Change the forwarding temporarily in your router so that Port 80 redirects directly to 192.168.1.10.
Enter abc.com in a web browser and see if abc.com properly comes up in your browser. There are many moving parts here, and everything must work properly before we move on to the proxy. You may want to test xyz.com as well.

Assuming you see your web page, we can move on the the proxy configuration.
Set up the proxy server so that when you type 192.168.1.5 in your web browser, you get the Apache splash page. This shows Apache is working.

In the proxy server, edit /etc/apache2/sites-available/abc.com.conf
Paste the following into the file:

   
<VirtualHost *:80>

ServerName abc.com
ServerAlias www.abc.com
Redirect Permanent /www.abc.com/ /abc.com/
   
   RequestHeader set X-Forwarded-Proto "https"
   RequestHeader set X-Forwarded-Port "443"

<Proxy *>
   Order deny,allow
   Allow from all
</Proxy>

   ProxyPreserveHost On
   ProxyPass / http://192.168.1.10:80/
   ProxyPassReverse / http://192.168.1.10:80/

   SSLProxyEngine on
   SSLEngine on
   Include /etc/letsencrypt/options-ssl-apache.conf
   SSLCertificateFile /etc/letsencrypt/live/abc.com/fullchain.pem
   SSLCertificateKeyFile /etc/letsencrypt/live/abc.com/privkey.pem