設定を自動的に行なう具体的な方法についてはいくつかのやり方があるようですが,自分にとっては以下の手順が簡単に思えたので記録しておくことにします。
状況
許可したIPアドレスからのアクセス以外を制限
127.0.0.1 WebRoleがlocalhostにアクセスする場合に許可
192.168.1.1 からのアクセスを許可
1.StartUp.cmd
WebRoleプロジェクトにテキストファイルとして StartUp.cmd を作成。
プロパティの[出力ディレクトリにコピー]を[常にコピーする]に設定。
以下の内容で保存。
@echo off %windir%\System32\ServerManagerCmd.exe -install Web-IP-Security %windir%\system32\inetsrv\AppCmd.exe unlock config -section:system.webServer/security/ipSecurity
2.ServiceDefinition.csdef
Windows Azureプロジェクトの ServiceDefinition.csdef に以下の内容を追記。
<WebRole>
<Startup>
<Task commandLine="StartUp.cmd" executionContext="elevated" taskType="simple" />
</Startup>
</WebRole>
3.Web.Config
WebRoleプロジェクトの Web.Config に以下の内容を追記。
<system.webServer>
<!--IPアドレスによるアクセス制限-->
<security>
<ipSecurity allowUnlisted="false">
<clear/>
<add ipAddress="127.0.0.1" allowed="true"/>
<add ipAddress="192.168.1.1" allowed="true" />
</ipSecurity>
</security>
</system.webServer>
参考
http://news.mynavi.jp/articles/2011/06/07/wings02/index.html
https://support.blacknight.ie/524/how-to-block-an-ip-address.html
0 件のコメント:
コメントを投稿