限制对staging和dev slot的访问

时间:2017-04-26 15:13:44

标签: azure iis web url-rewriting web-config

我需要限制访问我网站的登台和开发插槽。所以我在web.config中添加了这个规则(如here所述)

<rule name="Block unauthorized IP to staging/dev sites" stopProcessing="true">

    <match url=".*" />

    <conditions>
      <!-- Enter your staging site host name here as the pattern-->
      <add input="{HTTP_HOST}" pattern="myapp\-dev.azurewebsites.net"  />
      <add input="{HTTP_HOST}" pattern="myapp\-staging.azurewebsites.net" />

      <!-- Add the white listed IP addresses with a new condition as seen below -->
      <!-- <add input="{REMOTE_ADDR}" pattern="123\.123\.123\.2" negate="true"/> -->
    </conditions>

   <action type="Redirect" redirectType="Permanent" url="www.google.fr"/>
  </rule>

我需要限制对

的访问
  1. http://myapp-dev.azurewebsites.net
  2. http://myapp-staging.azurewebsites.net
  3. 它仍然可以访问。所以我需要知道如何解决这个问题?

    谢谢,

1 个答案:

答案 0 :(得分:1)

默认设置是匹配所有条件,但您只需要匹配一个,因为它是开发站点或暂存站点。您需要添加logicalGrouping =“MatchAny”,还需要将http://添加到www.google.fr。以下规则应该有效:

<rule name="Block unauthorized IP to staging/dev sites" stopProcessing="true">
      <match url=".*" />
      <conditions logicalGrouping="MatchAny">
        <add input="{HTTP_HOST}" pattern="myapp\-dev.azurewebsites.net" />
        <add input="{HTTP_HOST}" pattern="myapp\-staging.azurewebsites.net" />
        <!-- Enter your staging site host name here as the pattern-->
        <!-- Add the white listed IP addresses with a new condition as seen below -->
        <!-- <add input="{REMOTE_ADDR}" pattern="123\.123\.123\.2" negate="true"/> -->
      </conditions>

      <action type="Redirect" redirectType="Permanent" url="http://www.google.fr" />
</rule>