Apache VirtualHost Proxy – How to Configure with a Subdirectory

apache-2.2directoryPROXY

Currently, we have an IIS server as our primary web server. We are implementing an Apache server in its place, but still need to have the IIS server accessible. Typically, this is a simple thing, because Apache2 can proxy a subdomain to this server.

Our problem, however, is this: we are using dotnetCharting on the IIS server, and the licensing is tied to the domain name. In order to get dotnetCharting to work, another license will have to be purchased.

My question is, can Apache2 proxy a subdirectory? For example, can 'www.example.com/subdir' point to the IIS server? It seems like it shouldn't be impossible, but I can't seem to find a solution for this.

Best Answer

Sure. But be careful; a lot of web applications aren't designed well for having their URL path change. Is the application used in a sub-directory currently?

# You'll probably want this to maintain the host mapping in IIS
ProxyPreserveHost On
# Swap in the IP address or internal host name of your IIS server:
ProxyPass /subdir/ http://192.0.2.100/subdir/

Or, if you're altering the URL path, keeping in mind that a lot of applications will have problems with this, due to absolute paths for resources (CSS, javascript, images):

ProxyPass /subdir/ http://192.0.2.100/
ProxyPassReverse /subdir/ http://192.0.2.100/