【发布时间】:2014-03-04 00:16:29
【问题描述】:
我正在尝试使用 IIS 7.5、Application Request Routing 3.0 (ARR) 和 URL Rewrite 2.0 为 Jenkins 设置反向代理。
我的代理大部分都在工作,但遇到了包含百分号 (%) 的 URL 的问题。
无论我尝试什么,代理都会坚持对重写后的 URL 中的百分号进行解码或重新编码。
这就是我希望重写 URL 的方式:
http://my.proxy/a%2Fb -> http://my.host:8080/a%2Fb
这就是 实际上重写 URL 的方式:
http://my.proxy/a%2Fb -> http://my.host:8080/a/b
- or -
http://my.proxy/a%2Fb -> http://my.host:8080/a%252Fb
如何让 IIS\ARR\Rewrite 停止重新编码我重写的 URL?
我尝试过的事情:
-
一个普通的反向代理(将 URL 重写为
http://my.host:8080/a/b):<rule name="ReverseProxyInboundRule1" stopProcessing="true"> <match url="(.*)" ignoreCase="true" /> <action type="Rewrite" url="http://my.host:8080/{R:1}" /> </rule> -
使用
UNENCODED_URL服务器变量(将URL 重写为http://my.host:8080/a%252Fb):<rule name="ReverseProxyInboundRule1" stopProcessing="true"> <match url="(.*)" ignoreCase="false" /> <conditions logicalGrouping="MatchAll"> <add input="{UNENCODED_URL}" pattern="/(.*)" /> </conditions> <action type="Rewrite" url="http://my.host:8080/{C:1}" /> </rule> -
直接输入 URL(作为测试 - 还将 URL 重写为
http://my.host:8080/a%252Fb):<rule name="ReverseProxyInboundRule1" stopProcessing="true"> <match url="(.*)" ignoreCase="false" /> <action type="Rewrite" url="http://my.host:8080/a%2Fb" /> </rule> -
Scott Hanselman 出色的“Experiments in Wackiness: Allowing percents, angle-brackets, and other naughty things in the ASP.NET/IIS Request URL”中的所有想法
<httpRuntime requestValidationMode="2.0" requestPathInvalidCharacters="*,:,&amp;,\" relaxedUrlToFileSystemMapping="true" /><security> <requestFiltering allowDoubleEscaping="true" /> </security>'
注意:当我的 IIS 反向代理与 Jenkins' built-in reverse proxy checking system 发生冲突时,我遇到了这种行为,Jenkins' built-in reverse proxy checking system 试图将 HTTP 重定向到此表单的 URL。
【问题讨论】:
-
你有没有想过这个问题?我现在也有同样的问题...
-
不幸的是,没有。出于这个原因,我不再将 IIS 视为可接受的反向代理平台。
-
你改用了什么?
-
@Martin - 我一直使用 Apache。我试图在 Windows 机器上切换到 IIS,但没有成功。
标签: iis urlencode reverse-proxy url-rewrite-module arr