0

I currently have a Sub Domain Proxies and Sub Folder Proxies working as seperate virtual hosts.

I want to minimise/simplify the code by combining.

My end game is to have Subdomains pointing to different Physical/Virtual Servers, while use subfolders to access different services in that server.

For Example:

www.example.com = Server 0 Apache
www.example.com/webmin = Server 0 Webmin

server1.example.com = Server 1 Apache
server1.example.com/webmin = Server 1 Webmin
server1.example.com/ad = Server 1 Active Directory UI

server2.example.com = Server 2 Apache
server2.example.com/webmin = Server 2 Webmin
server2.example.com/ad = Server 2 Active Directory UI

I have the following working thou as separate VirtualHosts:

#NAS as nas.example.com
ProxyPass / http://10.0.28.1:5000/
ProxyPassReverse / http://10.0.28.1:5000/

#Webmin as nas.example.com/webmin
ProxyPass /webmin/ http://10.0.28.1:10000/
ProxyPassReverse /webmin/ http://10.0.28.1:10000/

My guess is the first entry is overriding the second as the first is /. I just can't seem to nut out how to override and make both ReverseProxies work within the same

  • ProxyPass directives are processed in order of the first match, simply list the one to the root `/` last rather than before `/webmin/` if that is your problem. - But Apache httpd can easily handle 100’s if not more VirtualHost entries and you can use the `Include` directive to load a common section into all VirtualHost entries, so I am not quite clear what you want to simplify in your config. – HBruijn Dec 22 '17 at 06:14
  • I thought I tried changing the order, but will try again. I wanted to simplify for readability. I was thinking of using macros later too. I was just hoping to have a single virtual host setup per server keeping all its settings together. – Shaun Williams Dec 22 '17 at 07:05
  • Somewhat related: https://serverfault.com/questions/799012/dynmap-throu-mod-proxy-on-a-external-webserver – Orphans Dec 22 '17 at 10:28

1 Answers1

0

Just tried reordering and it's still not working.

<VirtualHost *:443>
    # NAS
    ServerName nas.example.com
    ServerAdmin support@example.com
    DocumentRoot /mnt/WWW

    ProxyPass /webmin/ http://10.0.27.1:10000/
    ProxyPassReverse /webmin/ http://10.0.27.1:10000/

    ProxyPass / http://10.0.27.1:5000/
    ProxyPassReverse / http://10.0.27.1:5000/

    # SSL Certificates
    SSLEngine on
    SSLCertificateFile /root/ssl/example.com.crt
    SSLCertificateKeyFile /root/ssl/private.key
    SSLCACertificateFile /root/ssl/intermediateCA.crt

    # Error Logs
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

The above is a reverse proxy to another server (the NAS). nas.example.com should be the NAS's default GUI while nas.example.com/webmin should point to Webmin on the same server (NAS). What is happening thou is /webmin returns a page from the NAS GUI saying the page cannot be found.

  • Update: I got it working. Changing /webmin/ to /webmin fixed it. But am having issues with the redirect. A page under the subfolder to any server (not just webmin) will try to get CSS, JS, IMG etc from the parent domain. Looking in the source shows nas.example.com/style.css when it should be nas.example.com/webmin/style.css I need to work out how to force the subfolder to be the parent of the reverse proxy. – Shaun Williams Dec 22 '17 at 07:29
  • That's usually a configuration issue on the application server. – Gerald Schneider Dec 22 '17 at 07:39
  • https://serverfault.com/a/561897/37681 and the answer below mine for some thoughts on that – HBruijn Dec 22 '17 at 08:23