IIS 10 - URL 重写规则以阻止对 servername 的直接请求,SOAPUI 除外

IIS 10 - URL rewrite rules to block direct requests to servername except from SOAPUI

Window 2016/IIS 10。

我想阻止所有使用服务器名称的请求:portnumber/service 并强制使用 DNS 别名。目前的问题似乎是当规则 "Allow SOAPUI" 匹配时它不会停止处理,因此最后一个开始并阻止 SOAPUI

 <rule name="Allow SOAPUI" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
  <match url="*" />
  <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
    <add input="{HTTP_HOST}" pattern="dsttst100*" />
    <add input="{HTTP_USER_AGENT}" pattern="*SOAPUI*" negate="true" />
  </conditions>
  <action type="Rewrite" url="http://redirect.to.what" />
 </rule>
 <rule name="Only allow requests from loadbalancer" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
  <match url="*" />
  <conditions logicalGrouping="MatchAny" trackAllCaptures="false">
  <add input="{REMOTE_ADDR}" pattern="111.22.55.11" negate="true" />
  </conditions>
  <action type="CustomResponse" statusCode="403" subStatusCode="6" statusReason="Only allowed from IISAR01 (use DNS) or using SOAPUI" statusDescription="Use dns-alias" />
 </rule>

在尝试描述我的问题时,我确实找到了解决方案 - 至少是一种可能的解决方案。触发第二条规则的原因是,每当触发带有 servername:port 和 SOAPUI 用户代理的请求时,它都不匹配第一条规则……因为它是 SOAPUI。解决方案是创建第二条操作类型为 none if servername:portnumber AND SOAPUI 的规则。

<rule name="Servername - allow SOAPUI" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
   <match url="*" />
   <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
       <add input="{HTTP_HOST}" pattern="dsttst100*" />
       <add input="{HTTP_USER_AGENT}" pattern="*SOAPUI*" />
   </conditions>
   <action type="None" />
</rule>

这将阻止处理最后一条规则。