2013-05-29 113 views
1

我需要在我的Windows Azure網站上阻止除IP範圍以外的所有內容,但不幸的是我無法真正弄清楚它。Windows Azure網站 - 阻止IP範圍

我的web.config看起來是這樣的:

<configuration> 
<system.webServer> 
    <staticContent> 
     <mimeMap fileExtension=".svg" mimeType="image/svg+xml" /> 
    </staticContent> 
    <security> 
     <ipSecurity allowUnlisted="false"><!-- this line blocks everybody, except those listed below -->     
      <clear/><!-- removes all upstream restrictions --> 
      <add ipAddress="127.0.0.1" allowed="true"/>    
      <add ipAddress="MY IP" subnetMask="255.255.255.0" allowed="true"/>        
     </ipSecurity> 
    </security>  

我搜索了一個解決方案,但不能得到任何工作。 我可以看到ipSecurity需要在ApplicationHost.config中解鎖,但我無法弄清楚如何在他們的Azures網站解決方案中執行此操作。

所以我真的希望有人能幫助我或進一步解決問題。

回答

0

您可以通過創建一個啓動文件(STARTUP.CMD例如)解鎖web配置部分並在其屬性,選擇「總是複製到輸出」,然後調用這個在您的服務定義,像這樣:

<Startup><Task commandLine="startup.cmd" executionContext="elevated" taskType="simple"/></Startup> 

然後在您的STARTUP.CMD運行是這樣的:

%windir%\system32\inetsrv\AppCmd.exe unlock config /section:system.webServer/security/ipSecurity 

注意某些部分可以被解鎖,其他人不能,所以你可能需要解鎖的最高水平,或者它取決於以下兩個級別!

+1

問題是關於Azure網站,而不是Azure雲服務。這仍然是一個很好的答案,但不是這個問題。 – Carl