Search code examples
apacheproxyreverse-proxyhttpserverproxypass

Apache http proxy and reverse proxy


I need to define two virtual host that should forward my requests to different web applications. IP of PC where appache is installed is: 192.168.100.208. IP of application server where application are installed is: 192.168.100.50

<VirtualHost *:7778>
ServerName 192.168.100.208

ProxyRequests On
ProxyPreserveHost Off
<Proxy *>
    Order allow,deny
    Allow from all
</Proxy>
ProxyErrorOverride On

ProxyPass / http://192.168.100.50:9081/app1/
ProxyPassReverse / http://192.168.100.50:9081/app1/

 <Location>
            Order allow,deny
            Allow from all
</Location>

and I need to have:

<VirtualHost *:7777>
ServerName 192.168.100.208

ProxyRequests On
ProxyPreserveHost Off
<Proxy *>
    Order allow,deny
    Allow from all
</Proxy>
ProxyErrorOverride On

ProxyPass / http://192.168.100.50:9081/app2/
ProxyPassReverse / http://192.168.100.50:9081/app2/

 <Location>
            Order allow,deny
            Allow from all
</Location>

So when I type in browser:

192.168.100.208:7778 i should get page from 192.168.100.50:9081/app1

and

192.168.100.208:7777 i should get page from 192.168.100.50:9081/app2

But above is not working. Where is mistake?


Solution

  • Make sure to have the following configured also:

    #
    # Use name-based virtual hosting.
    #
    NameVirtualHost *:7778
    NameVirtualHost *:7777