I am trying to do Reverse Proxy with ARR and URL rewrite to achieve below redirection:
The final URL displayed will be same as the source URL.
Redirection works fine, however all my JavaScript files are getting converted to content-type text/html
instead of application/javascript
when browsed externally. This results in a blank page instead of actual functionality.
Rewrite rule:
<rules>
...
<rule name="ReverseProxyInboundRule2" stopProcessing="true">
<match url="^test(.*)" />
<action type="Rewrite" url="http://{HTTP_HOST}:83/{R:1}" />
</rule>
</rules>
<outboundRules>
<rule name="ReverseProxyOutboundRule1" preCondition="IsJavascript">
<match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" customTags="" pattern="^http(s)?://localhost:83/(.*)" />
<action type="Rewrite" value="http{R:1}:{HTTP_HOST}/{R:2}" />
</rule>
<preConditions>
<preCondition name="IsJavascript">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^application/javascript" />
</preCondition>
</preConditions>
</outboundRules>
The destination page uses AJAX functionality and since the js files are corrupted with random html tags, causing AJAX functions to fail. How can I correct this?
Finally figured the issue was due to relative paths in the destination application. Once proxied, the js, css and other links were redirecting to a custom 404 error page which is a part of source application. I have fixed the issue by modifying the code.