I am working my way through establishing IIS as a reverse-proxy. I have set up two internal sites (served by IIS) termed Payroll and Webmail, and one external site (served by a different web server) termed IPS. All three sites are on localhost, but Payroll binds to port 12084, Webmail to port 12085, and IPS to port 2080 I have then created three inbound rules which directs xyz.com/ips/, xyz.com/payroll/, and xyz.com/webmail/ to their respective servers. All of this works just fine.
<rules>
<rule name="Reverse Proxy to ips" enabled="true"
stopProcessing="true">
<match url="^ips/(.*)" />
<action type="Rewrite" url="http://localhost:2080/{R:1}" />
<serverVariables>
<set name="HTTP_ACCEPT_ENCODING" value="" />
</serverVariables>
</rule>
<rule name="Reverse Proxy to webmail" stopProcessing="true">
<match url="^webmail/(.*)" />
<action type="Rewrite" url="http://localhost:12084/{R:1}" />
<serverVariables>
<set name="HTTP_ACCEPT_ENCODING" value="" />
</serverVariables>
</rule>
<rule name="Reverse Proxy to payroll" stopProcessing="true">
<match url="^payroll/(.*)" />
<action type="Rewrite" url="http://localhost:12085/{R:1}" />
<serverVariables>
<set name="HTTP_ACCEPT_ENCODING" value="" />
</serverVariables>
</rule>
</rules>
I have then written one outbound rule which should patch the URLs so that they will work from external clients.
<rule name="Add application prefix" preCondition="IsHTML">
<match filterByTags="A, Area, Base, Form, Frame, Head, IFrame,
Img, Input, Link, Script" pattern="^/(.*)" />
<conditions>
<add input="{URL}" pattern="^/(webmail|payroll|ips)/.*" />
</conditions>
<action type="Rewrite" value="/{C:1}/{R:1}" />
</rule>
<preConditions>
<preCondition name="IsHTML">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</preConditions>
And that’s where the trouble starts. Payroll and Webmail work just fine: they are test sites containing just a href to themselves, which gets patched correctly. IPS, however, is a different story. You see, IPS/index.html contains a redirect to /html/index.php.
<meta HTTP-EQUIV="REFRESH" content="0; url=/html/index.php">
Now comes my question. For reasons that I do not fully understand, this redirect does not get patched, and as a result the client ends up in the "eternal pastures".
My suspicion is that the outbound rule works only for sites served by IIS itself, but will not affect external servers. My further suspicion is that I could make this work by defining IPS (localhost:2080) as a server in the “Server Farm”, and tweak the outbound rule accordingly. I am wondering whether the above is correct, and – if so – how should the outbound rule be patched.
0 Answers