I'm currently working on setting up a Reverse Proxy with ARR and URL rewrite in order to achieve the following redirection:
- Source: http://localhost/test
- Destination: http://localhost:83/
The goal is for the final URL displayed to be same as the source URL.
While the redirection works correctly, all my JavaScript files are being transformed into content-type text/html
instead of application/javascript
when accessed externally. This results in a blank page instead of the expected functionality.
Here is the Rewrite rule I am using:
<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>
Since the destination page relies on AJAX functionality and the javascript files are being corrupted with random html tags, the AJAX functions are failing. How can I go about fixing this issue?