LoginSignup
0
0

More than 5 years have passed since last update.

CloudFlare + Azure Web Appsの環境でIP制限を掛ける時のweb.config

Last updated at Posted at 2018-01-25

はじめに

CloudFlareCDN経由でWebAppsのコンテンツ公開する際に一時的にIP制限を掛けたい場合はどうやればよいのか少し調べてみました。

設定内容

設定は次の通りです。
ポイントはCDNやLB等を経由すると送信元IPが書き換わるのを考慮しx-forwarded-forで判断するようenableProxyMode="true"にします。

web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <security>
      <ipSecurity enableProxyMode="true" allowUnlisted="false" >
       <!-- Your IP -->
       <add allowed="true" ipAddress="1.2.3.4" />
       <!-- CLOUDFLARE -->
       <add allowed="true" ipAddress="199.27.128.0" subnetMask="255.255.248.0" />
       <add allowed="true" ipAddress="173.245.48.0" subnetMask="255.255.240.0" />
       <add allowed="true" ipAddress="103.21.244.0" subnetMask="255.255.252.0" />
       <add allowed="true" ipAddress="103.22.200.0" subnetMask="255.255.252.0" />
       <add allowed="true" ipAddress="103.31.4.0" subnetMask="255.255.252.0" />
       <add allowed="true" ipAddress="141.101.64.0" subnetMask="255.255.192.0" />
       <add allowed="true" ipAddress="108.162.192.0" subnetMask="255.255.192.0" />
       <add allowed="true" ipAddress="190.93.240.0" subnetMask="255.255.240.0" />
       <add allowed="true" ipAddress="188.114.96.0" subnetMask="255.255.240.0" />
       <add allowed="true" ipAddress="197.234.240.0" subnetMask="255.255.252.0" />
       <add allowed="true" ipAddress="198.41.128.0" subnetMask="255.255.128.0" />
       <add allowed="true" ipAddress="162.158.0.0" subnetMask="255.254.0.0" />
       <add allowed="true" ipAddress="104.16.0.0" subnetMask="255.240.0.0" />
      </ipSecurity>
    </security>
  </system.webServer>
</configuration>

過不足ありましたらご指摘くださいませ。

参考サイト

Azure website IP restriction

CloudFlare IP Ranges

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0