限制对登台和开发插槽的访问

restrict access to staging and dev slots

我需要限制对我网站的登台和开发插槽的访问。所以我在 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

它仍然可以访问。所以我需要知道如何解决这个问题?

谢谢,

默认匹配所有条件,但您只需匹配一个,因为它是开发站点或临时站点。您需要添加 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>