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.

        <rule name="Reverse Proxy to ips" enabled="true" 
            <match url="^ips/(.*)" />
            <action type="Rewrite" url="http://localhost:2080/{R:1}" />
                    <set name="HTTP_ACCEPT_ENCODING" value="" /> 

            <rule name="Reverse Proxy to webmail" stopProcessing="true">
            <match url="^webmail/(.*)" />
            <action type="Rewrite" url="http://localhost:12084/{R:1}" />
                    <set name="HTTP_ACCEPT_ENCODING" value="" /> 

            <rule name="Reverse Proxy to payroll" stopProcessing="true">
            <match url="^payroll/(.*)" />
            <action type="Rewrite" url="http://localhost:12085/{R:1}" />
                    <set name="HTTP_ACCEPT_ENCODING" value="" /> 

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="^/(.*)" />
                    <add input="{URL}" pattern="^/(webmail|payroll|ips)/.*" />
                <action type="Rewrite" value="/{C:1}/{R:1}" />
                <preCondition name="IsHTML">
                    <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />

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.

  • Have you tried removing the <match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" pattern="^/(.*)" /> tag from the last rule? – Mathias R. Jessen Dec 25 '12 at 8:51
  • Thanks Mathias for helping immediately on Xmas! I have just tried your suggestion, and that results in an endless loop (output is: /ips//ips//ips//ips//...). It just keeps adding "/ips/" to the output... – aag Dec 25 '12 at 9:09
  • Christmas is a time of the truly needy, I'm glad to help ^_^ Could you post the last inbound rewrite rule as well? The example only shows the /webmail and /payroll rules, not the /ips rule :) – Mathias R. Jessen Dec 25 '12 at 9:35
  • oops. somehow the IPS rule was hidden by a misformatted quote. It's now corrected. – aag Dec 25 '12 at 10:30
  • 1
    I am quite convinced that the problem lies within the outbound rule. If I request directly the redirect target page (=/html/index.php) things work (more-or-less) OK. This is very mysterious! – aag Dec 25 '12 at 14:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.