Search code examples
apacheproxyreverse-proxy

Apache VirtualHost directive ProxyPass


I want to use Apache as a proxy for two different sites hosted on different machines. I am currently running Apache 2.2.15.

What I want to achieve is:

 Client --> https://ApacheWebProxyPubIP:443
        --> /Url1.php --> http://10.0.0.2/Url1.php
        --> /Url2 --> http://10.0.0.3/Url2

I tried using:

     VirtualHost default:443
         ServerName something.nice.org
         ProxyPass /Url1.php http://10.0.0.2/Url1.php
         ProxyPassReverse /Url1.php http://10.0.0.2/Url1.php
     VirtualHost
     VirtualHost *:443
         ServerName somethingelse.nice.org
         ProxyPass /Url2 http://10.0.0.3/Url2
         ProxyPassReverse /Url2 http://10.0.0.3/Url2
     VirtualHost *:443
     

The /Url1.php to http://10.0.0.2/Url1.php works fine but Url2 is not forwarded to 10.0.0.3.

What would be the correct syntax to achieve this?

Thanks!


Solution

  • Try this in your <VirtualHost> directive:

         ServerName something.nice.org
         ServerAlias somethingelse.nice.org
    
         ProxyPass /Url1.php http://10.0.0.2/Url1.php
         ProxyPassReverse /Url1.php http://10.0.0.2/Url1.php
    
         ProxyPass /Url2 http://10.0.0.3/Url2
         ProxyPassReverse /Url2 http://10.0.0.3/Url2