Using URL Rewrite for Cross-Domain Http Requests

我只是一个虾纸丫 提交于 2019-12-13 02:56:34

问题


I am trying to write an inbound rewrite rule that basically captures all the requests to the root folder /api/*, and rewrite it to api.v2.movideo.com respecting the HTTP vs HTTPS traffic.

I followed the step by step instructions here: http://code.movideo.com/Setting_up_IIS7_to_use_URL_Rewrite_2.0_for_Cross-Domain_XMLHttpRequest_Calls

I installed Application Request Routing http://www.iis.net/expand/URLRewrite Followed all the steps on that page, removed the instructed headers, did everything by the book, but all I get is this:

HTTP Error 500.50 - URL Rewrite Module Error. There is a problem with the resource you are looking for, so it cannot be displayed.

When I change the rule from REWRITE to REDIRECT, it works fine, but it redirects, not rewrites! Ugh. What's going on here?

Here is my Rule:

            <rule name="ReverseProxyInboundRule1" stopProcessing="false">
                <match url="^api/(.*)" />
                <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                    <add input="{CACHE_URL}" pattern="^(https?)://" />
                </conditions>
                <action type="Rewrite" url="{C:1}://api.movideo.com/{R:1}" />
                <serverVariables>
                    <set name="HTTP_ACCEPT_ENCODING" value="" />
                </serverVariables>
            </rule>

(2nd question: Are there any problems or things I should know installing Application Request Routing? It added a new 'Server Farms' section in my IIS, hmmmm...I have no idea what this is all about. )


回答1:


  1. If there are processing rules AFTER this rule, consider setting the stopProcessing attribute to true
  2. Because you are using a serverVariables node, you must add the server variable to the allowedServerVariables collection for your server. Your can do this from using the IIS UI (details here: Setting HTTP request headers and IIS server variables) or from the command line:

    %windir%\System32\inetsrv\appcmd.exe set config -section:system.webServer/rewrite/allowedServerVariables /+"[name='boo']" /commit:apphost



来源:https://stackoverflow.com/questions/20886420/using-url-rewrite-for-cross-domain-http-requests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!