iis-6reverse-proxyisapi-rewrite

Configuring a reverse proxy on IIS 6 with Isape_Rewrite3


I'm running IIS6 on Windows Server 2003.

I am trying to set up a tool on one of my websites that requires a reverse proxy.

As I understand it, I need to capture a script reference pointing at my.domain.com/toolname/subfolder/javascript.js to pull the file from library.provider.com/javascript.js.


The examples given by the tool provider are,

"In Apache2, add this to your <VirtualHost> entry for the site:"

ProxyPass /subfolder/ http://library.provider.com/
ProxyPassReverse /subfolder/ http://library.provider.com/

"In NGINX, add this to your server block for the site:"

location /subfolder/ {
    proxy_pass http://library.provider.com/;
}

I tried the example found in the SO question, URL Rewrite of a subdirectory to a different domain using IIS, adjusting it to my situation:

RewriteCond Host: (.*)
RewriteRule ^/subfolder/$|^/subfolder/(.*) http://library.provider.com/$1 [P]

This did not appear to work... the RewriteLog looks like this:

... (2) init rewrite engine with requested uri /subfolder/javascript.js
... (1) Htaccess process request [drive]:[path]\httpd.conf
... (1) Htaccess process request [drive]:[path]\my.domain.com\.htaccess
... (3) applying pattern '^/subfolder/$|^/subfolder/(.*)' to uri 'subfolder/javascript.js'

I notice that the 'uri' string in the last entry doesn't include the leading forward slash, but aside from that I'm stumped.

I tested the pattern match using the built-in 'RegEx Test' tool, and if I passed /subfolder/javascript.js I get http://library.provider.com/javascript.js as expected.

It seems that I am really close to the answer, and any help would be greatly appreciated.


Solution

  • Please try the following config in your .htaccess:

    RewriteBase /
    RewriteRule ^subfolder/(.*) http://library.provider.com/$1 [NC,P]