[英]IIS Reverse proxy/Global URL Rewrite for “/api/” folder for all sites
I would like to reverse proxy any requests to an IIS instance for any sites where the request is in the '/api/' folder.对于请求位于“/api/”文件夹中的任何站点,我想将任何请求反向代理到 IIS 实例。 I set up a server farm and have the reverse proxy working for everything using the '*' wildcard, but when I want to limit the scope to a RegEx it will not rewrite/proxy to the backend server.我设置了一个服务器场,并让反向代理使用“*”通配符为所有内容工作,但是当我想将 scope 限制为 RegEx 时,它不会重写/代理到后端服务器。 The steps I took at the IIS INSTANCE level:我在 IIS INSTANCE 级别采取的步骤:
Below is a snippet from my applicationHost.config [the root of IIS].下面是我的 applicationHost.config [IIS 的根目录] 的一个片段。
<rewrite>
<globalRules>
<rule name="ARR_Farm1_loadbalance" patternSyntax="ECMAScript" stopProcessing="true">
<match url=".*(\/.*\/api\/.*)" />
<action type="Rewrite" url="http://Farm1/{R:1}" />
</rule>
</globalRules>
</rewrite>
<proxy enabled="true" />
Is it possible to to a global URL re-write to the server farm for any site on the instance for specific folders?是否可以将全局 URL 重新写入服务器场以针对特定文件夹的实例上的任何站点?
Edit: It was answered below - I am including a picture in case others run into this.编辑:它在下面得到了回答——我附上了一张照片,以防其他人遇到这个问题。 The test pattern isn't clear to me - and counters documentation found here .测试模式对我来说不是很清楚 - 并且计数器文档在这里找到。
Your pattern is incorrect, you can try below code, and change the rewrite url to https://Farm1/ {R: 0}您的模式不正确,您可以尝试以下代码,并将重写 url 更改为https://Farm1/ {R: 0}
<rule name="ARR_Farm1_loadbalance" patternSyntax="ECMAScript" stopProcessing="true">
<match url=".*(\/api\/.*)" />
<action type="Rewrite" url="https://Farm1/{R:0}" />
</rule>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.