Search code examples
reverse-proxyapache-configmod-proxy

Apache Config to send sub dirs to different servers - mod_proxy


We use Apache as a reverse proxy server. This has been working well, but I now need to have http://domain.com/sub1 proxy to serverA and http://domain.com/sub2 proxy to serverB. Is this possible? If so, what is the config for it?

Here is my existing config:

...
<VirtualHost 555.55.555.555:80>
ServerName domain.com
DocumentRoot c:/docroot

ProxyPass / http://serverA/
ProxyPassReverse / http://serverA/
</VirtualHost>
...

Solution

  • You've almost got it. You want something like:

    ProxyPass /sub1 http://serverA/
    ProxyPassReverse /sub1 http://serverA/
    ProxyPass /sub2 http://serverB/
    ProxyPassReverse /sub2 http://serverB/
    

    Check out the documentation for the ProxyPass directive, there are some neat tricks you can do with it.