Reputation: 97
I have a site1
which is a web client application. site1
calls some site2
APIs which is running into CORS
issue.
I have written rewrite rules in IIS to rewrite the request matching string extFlow
in the URL.
From https://site1/xyz/extFlow/Test.svc/testAPI
to https://site2/extFlow/Test.svc/testAPI
Following is my rewrite rule. The response seems to be written back to https://site1/extFlow/Test.svc/testAPI
and not https://site1/xyz/extFlow/Test.svc/testAPI
. If site2
responds with 500
, the final response from IIS reverse proxy is 404
.
<rewrite>
<rules>
<rule name="Route the requests for WFL" stopProcessing="true">
<match url="extFlow/(.*)" />
<conditions>
</conditions>
<action type="Rewrite" url="https://site2/extFlow/{R:1}" logRewrittenUrl="true" />
<serverVariables>
<set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="{HTTP_ACCEPT_ENCODING}" />
<set name="HTTP_ACCEPT_ENCODING" value="" />
</serverVariables>
</rules>
<outboundRules>
<rule name="ReverseProxyOutboundRule1" preCondition="NeedsResportingAcceptResp" stopProcessing="true">
<match filterByTags="A" serverVariable="HTTP_ACCEPT_ENCODING" pattern="^(.*)" />
<action type="Rewrite" value="{HTTP_X_ORIGINAL_ACCEPT_ENCODING}" />
</rule>
<preConditions>
<preCondition name="NeedsResportingAcceptResp">
<add input="{HTTP_X_ORIGINAL_ACCEPT_ENCODING}" pattern=".+" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
<handlers>
<remove name="svc-ISAPI-4.0_64bit" />
<remove name="svc-ISAPI-4.0_32bit" />
<remove name="svc-Integrated-4.0" />
</handlers>
Upvotes: 0
Views: 1691
Reputation: 48
Maybe is an outbound rule missing?
<rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
<match filterByTags="None" pattern="^https://site2/extFlow($|/(.*))" />
<action type="Rewrite" value="https://site1/xyz/extFlow/{R:2}" />
</rule>
Upvotes: 1