Search code examples
apachetomcatproxypass

How can I setup an Apache ProxyPass to a subdirectory which overrides a parent ProxyPass?


I have multiple web servers running on a given machine (Apache, Tomcat, custom Python servers). I have Apache listening on port 80, as is the standard setup. In order to access one of my other servers over this port, I setup a ProxyPass in Apache like this:

ProxyPass / http://[mydomainname]:8880/
ProxyPassReverse / http://[mydomainname]:8880/

It works. When you browse to the domain name, with no port spec (since 80 is implied), instead of reaching the Apache root, you are transparently redirected to the root of another server on the machine (a Twisted server) listening on port 8880.

Here's the problem. It seems I have blocked anything from reaching my Apache files now. Is there a way to override that root proxy pass for various sub directories? For example, if you browse to mydomain/test can I get that to work as though I had no proxy pass at all, rather than routing that to a path on the port 8880 server?


Solution

  • I found the answer on the SO thread: ProxyPass and DocumentRoot on one domain.

    BEFORE the root ProxyPass directive, just add a ProxyPass exclusion and a directory alias. Note: repeat for each Apache sub directory to be exposed.

    ProxyPass /MySubDirectory !
    Alias /MySubDirectory /var/www/html/MySubDirectory