了解 IIS 代理响应 header 重写规则
understanding IIS Proxy response header rewrite Rule
我们有一个 IIS 反向代理响应规则,它修改 Location HTTP header..我正在尝试解码逻辑并计划在 xslt 中编写相同的逻辑,有人可以解释下面的逻辑。匹配模式如何工作以及动作重写和值如何工作以及这里的 R:1、R:2、R:3 是什么?
<rule name="Change Location Header" enabled="true">
<match serverVariable="RESPONSE_LOCATION" pattern="^http(s)?://([^/]+)/(.*)" />
<conditions logicalGrouping="MatchAny" trackAllCaptures="true">
<add input="{RESPONSE_STATUS}" pattern="^301" />
<add input="{RESPONSE_STATUS}" pattern="^302" />
</conditions>
<action type="Rewrite" value="http{R:1}://{R:2}/{R:3}" />
</rule>
您的规则正在更改重定向响应的 HTTP 位置 header 中的域
工作匹配条件如何以及什么是R:1,R:2,R:3
RESPONSE_LOCATION
变量已满 url。例如:
https://demo.cloudimg.io/s/width/300/sample.li/boat.jpg
在这种情况下,在使用正则表达式进行匹配操作后:^http(s)?://([^/]+)/(.*)
Mathces 会是这样的:
{R:0} https://demo.cloudimg.io/s/width/300/sample.li/boat.jpg
{R:1} s
{R:2} demo.cloudimg.io
{R:3} s/width/300/sample.li/boat.jpg
我们有一个 IIS 反向代理响应规则,它修改 Location HTTP header..我正在尝试解码逻辑并计划在 xslt 中编写相同的逻辑,有人可以解释下面的逻辑。匹配模式如何工作以及动作重写和值如何工作以及这里的 R:1、R:2、R:3 是什么?
<rule name="Change Location Header" enabled="true">
<match serverVariable="RESPONSE_LOCATION" pattern="^http(s)?://([^/]+)/(.*)" />
<conditions logicalGrouping="MatchAny" trackAllCaptures="true">
<add input="{RESPONSE_STATUS}" pattern="^301" />
<add input="{RESPONSE_STATUS}" pattern="^302" />
</conditions>
<action type="Rewrite" value="http{R:1}://{R:2}/{R:3}" />
</rule>
您的规则正在更改重定向响应的 HTTP 位置 header 中的域
工作匹配条件如何以及什么是R:1,R:2,R:3
RESPONSE_LOCATION
变量已满 url。例如:
https://demo.cloudimg.io/s/width/300/sample.li/boat.jpg
在这种情况下,在使用正则表达式进行匹配操作后:^http(s)?://([^/]+)/(.*)
Mathces 会是这样的:
{R:0} https://demo.cloudimg.io/s/width/300/sample.li/boat.jpg
{R:1} s
{R:2} demo.cloudimg.io
{R:3} s/width/300/sample.li/boat.jpg