Windows Azure具有WCF Web角色并通过web.config限制IP

时间:2013-10-24 18:07:39

标签: wcf security azure config

我正在尝试仅将某些IP地址限制为我的Azure托管WCF服务。我已按照以下网站上列出的两条说明进行操作:

http://msdn.microsoft.com/en-us/library/windowsazure/jj154098.aspx

http://blog.elastacloud.com/2011/04/06/restricting-access-by-ip-in-azure-web-role-v1-4/

但我仍然可以从未列出的地址访问该服务。有什么我想念的吗?

这是cmd文件:

@echo off

@echo Installing “IPv4 Address and Domain Restrictions” feature
%windir%\System32\ServerManagerCmd.exe -install Web-IP-Security

@echo Unlocking configuration for “IPv4 Address and Domain Restrictions” feature
%windir%\system32\inetsrv\AppCmd.exe unlock config -section:system.webServer/security/ipSecurity

web.config部分:

<system.webServer>
   <security>
   <!-- IP addresses are denied access -->
    <ipSecurity allowUnlisted="false">
        <!--The following IP addresses are granted access -->
        <clear />
        <add allowed="true" ipAddress="x.x.x.x" />
    </ipSecurity>
   </security>
  </system.webServer>

1 个答案:

答案 0 :(得分:2)

感谢Rick Rainey,我发现我可以将RDP转换为Web角色并手动运行脚本。我发现脚本的第一部分失败了,因为应用程序在服务器2012上运行。我将其更改为:

powershell -ExecutionPolicy Unrestricted -command&#34; Install-WindowsFeature Web-IP-Security&#34;

现在一切都按预期工作......