How do I setup an Apache double reverse proxy?

Just to make life difficult - I'm trying to setup a double reverse proxy:

WWW > Router > Apache Reverse Proxy #1 (443) > Apache Reverse Proxy (443) #2 > Docker Container (Which runs on same machine as #2)

Both reverse proxies have FQDNs. I'm trying to use Virtual Hosts but clearly don't understand how to set up the proxy.

The main domain is example.com (hosted on Apache #1), and subdomain office.example.com (hosted on Apache #2).

On Apache #1 I have to Virtual Hosts setup (example.com and office.example.com). The virtual host file for office.example.com appears like this:

<VirtualHost *:443> ServerName office.example.com UseCanonicalName off DirectoryIndex index.html index.htm /index.php index.php DocumentRoot /usr/local/www/office .... .... # keep the host ProxyPreserveHost On ProxyPass / ProxyPassReverse / .... ....
</VirtualHost>

My DNS records are at Cloudflare and both office.example.com and example.com resolve to the same external IP address. The pfSense router however has a DNS Override that reassigns office.example.com to an internal LAN address

On Apache #2 my virtual host file appears as the following:

<VirtualHost *:443> ServerName office.example.com DocumentRoot "/var/www/" DirectoryIndex index.html index.htm /index.php index.php ... ... ProxyPreserveHost On # static html, js, images, etc. served from loolwsd # loleaflet is the client part of LibreOffice Online ProxyPass /loleaflet retry=0 ProxyPassReverse /loleaflet ... ...
</VirtualHost>

I left out the SSL encryption items as SSL transport is involved from Web to Apache #1 and SSL encryption from Apache #1 to Apache #2. SSL terminates at the 2nd proxy.

From the outside I can reach which correctly displays the index.html file located at Document Root on Apache #2.

However any other link I can't resolve. I get a 500 error if I try: or .

I think I'm missing something with the reverse proxy requests.

2

1 Answer

As recommended above, I partly found an answer for this question. For HTTP/HTTPS links you need to add a / behind the URL. So:

ProxyPass / ProxyPassReverse / 

Needs to be written as

ProxyPass / ProxyPassReverse / 

This solves one problem which I'll accept however unfortunately this doesn't work if you need to ProxyPass ws/wss links. I'm still looking for a solution for that problem.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like