0

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 / https://office.example.com
    ProxyPassReverse / https://office.example.com

    ....
    ....
</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/office.example.com/html"
    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 http://127.0.0.1:9980/loleaflet retry=0
    ProxyPassReverse /loleaflet http://127.0.0.1:9980/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 https://office.example.com 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: https://office.example.com/data or https://office.example.com/loleaflet.

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

  • I figured this problem out for http/https connections. The solution unfortunately came down to the following: Changed: ProxyPass / https://office.domain.com ProxyPassReverse / https://office.domain.com to ProxyPass / https://office.domain.com/ and Proxy Pass Reverse / https://office.domain.com/ – KevDog Oct 6 at 2:55
  • Interesting situation. If you found a solution, please feel free to post an answer and self-accept it. Also note how I have code commented your URLs and domains to avoid anyone actually linking them as well as changing them to example.com which is the accepted “fake” domain used on these sites for example cases. – JakeGould Oct 6 at 3:11
0

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 / https://office.example.com
    ProxyPassReverse / https://office.example.com

Needs to be written as

ProxyPass / https://office.example.com/
    ProxyPassReverse / https://office.example.com/

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

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.