繁体   English   中英

如何在IIS上配置一个URL重写/代理规则?

[英]How to configure one URL Rewrite/proxy rules on IIS?

架构:用户 - > ARR服务器 - > LB - > 2 Web服务器服务2个不同的站点Web Server1服务 - > https://xxxx-green-xxxx-xxxx.net/xxx/xxx?xx=xxxx其中绿色关键字来自域名Web Server2服务中的任何位置 - > https://xxxx-yellow-xxxx-xxxx.net/xxx/xxx?xx=xxxx其中黄色关键字出现在域名的任何位置

要求:请求格式: https ://xxxx-green-xxxx-xxxx.net/xxx/xxx?xx =xxxx或黄色URL在ARR中,我们需要使用URL中的绿色和黄色关键字过滤URL并将其发送到相应的Web服务器IP。

但我的所有请求都只登陆主页。 甚至我感到困惑的是,更改主机是否会工作,但我需要为LB中的每个Web服务器提供不同的IP

我们设置了此规则并得到以下结果:

                <rule name="Green" enabled="true" stopProcessing="true">
                <match url="(.*xxx.net)(/.*)" />
                <conditions logicalGrouping="MatchAll" 
                 trackAllCaptures="false">
                    <add input="{HTTP_HOST}" pattern="green" />
                </conditions>
                <action type="Rewrite" url="https://xx.xxx.xx.xx/{R:2}" 
                 appendQueryString="true" />
                 </rule> 
                 Where R:2 is --> xxx/xxx?xx=xxxx

根据你的问题。

您需要为此编写自定义重写规则。 所以首先请参考链接

进入链接,您可以处理您的要求并重写到其他其他Web服务器。

所以请按照所有步骤,写下你的逻辑
重写(字符串值)方法。

在此方法中,您需要从IIS规则传递服务器URL并通过以下条件检查。

 public string Rewrite(string value)
  {
      if(value.Contains("green"))
        {
         return // your rewrite URL here
        }
      else if(value.Contains("yellow"))
        {
         return // your rewrite URL here
        }
    return value;
  }

所以它按照你的要求工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM