反向代理响应 404 错误,错误时响应 URL 不正确

Reverse proxy responding with 404 error and response URL incorrect when error

我有一个 site1,它是一个 Web 客户端应用程序。 site1 调用一些 site2 API 是 运行 进入 CORS 问题。

我在IIS中写了重写规则来重写URL中的请求匹配字符串extFlow

来自https://site1/xyz/extFlow/Test.svc/testAPIhttps://site2/extFlow/Test.svc/testAPI

以下是我的重写规则。响应似乎被写回到 https://site1/extFlow/Test.svc/testAPI 而不是 https://site1/xyz/extFlow/Test.svc/testAPI。如果 site2 响应 500,IIS 反向代理的最终响应是 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>

可能缺少出站规则?

<rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1"> 
    <match filterByTags="None" pattern="^https://site2/extFlow($|/(.*))" /> 
    <action type="Rewrite" value="https://site1/xyz/extFlow/{R:2}" /> 
 </rule>