I am trying to set up a reverse proxy, using the tutorials here, here and here.
The site is set up on localhost:8080
, with the reverse proxy using localhost:8080/myProxy
.
When dealing with standard links, all is fine. I can view the proxy url and see everything as expected. A link from localhost:8080/myProxy/default.aspx
goes to localhost:8080/myProxy/about.aspx
as expected.
The problem I have is that where .NET Response.Redirect()
is used, the url changes to the websites actual location instead of the proxy.
i.e. the link goes from localhost:8080/myproxy/default.aspx
-> localhost:8080/about.aspx
.
How can i resolve this please?
Here is my config:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<urlCompression doStaticCompression="false" doDynamicCompression="false"
dynamicCompressionBeforeCache="false" />
<rewrite>
<rules>
<rule name="Reverse Proxy to my site" stopProcessing="true">
<match url="^myProxy/(.*)" />
<action type="Rewrite" url="http://localhost:8080/{R:1}" />
</rule>
</rules>
<outboundRules>
<rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
<match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script"
pattern="^http(s)?://localhost:8080/(.*)" />
<action type="Rewrite" value="/myProxy/{R:2}" />
</rule>
<rule name="RewriteRelativePaths" preCondition="ResponseIsHtml1">
<match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script"
pattern="^/(.*)" negate="false" />
<action type="Rewrite" value="/myProxy/{R:1}" />
</rule>
<preConditions>
<preCondition name="ResponseIsHtml1">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
</system.webServer>