0
votes

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!

2
If the Client is typing ApacheWebProxyPubIP, then VirtualHost withServerName somethingelse.nice.org will never be used - Dusan Bajic
But both something and somethingelse resolves to the same single public IP and both depend on the same port. How can I then point /Url1.php somewhere and /Url2 somewhere else? - Andy Thompson

2 Answers

0
votes

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
0
votes

Use the

ProxyPreserveHost yes

directive. Tells the forwarding server to preserve the host name (which is forwarded by the client).