Azure website IP restriction

前端 未结 3 1484
醉酒成梦
醉酒成梦 2020-12-20 21:40

I have an Azure website which I only use for development and testing, therefore I want to restrict access to it for everyone but myself. According to this blog article this

相关标签:
3条回答
  • 2020-12-20 22:10

    Just in case someone is trying to setup IP restrictions with Cloudflare: the solution is to not only add your IP to the whitelist, but also all the Cloudflare IPs (taken from here).

    <system.webServer>
        <security>
            <ipSecurity enableProxyMode="true" allowUnlisted="false" denyAction="NotFound">
                <!-- 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>
    
    0 讨论(0)
  • 2020-12-20 22:13

    Not intended as a full answer, just posting a slightly updated list of CloudFlare IPs in useful copy/paste format. See the accepted answer for usage.

        <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="104.16.0.0" subnetMask="255.240.0.0" />
        <add allowed="true" ipAddress="108.162.192.0" subnetMask="255.255.192.0" />
        <add allowed="true" ipAddress="131.0.72.0" subnetMask="255.255.252.0" />
        <add allowed="true" ipAddress="141.101.64.0" subnetMask="255.255.192.0" />
        <add allowed="true" ipAddress="162.158.0.0" subnetMask="255.254.0.0" />
        <add allowed="true" ipAddress="172.64.0.0" subnetMask="255.248.0.0" />
        <add allowed="true" ipAddress="173.245.48.0" subnetMask="255.255.240.0" />
        <add allowed="true" ipAddress="188.114.96.0" subnetMask="255.255.240.0" />
        <add allowed="true" ipAddress="190.93.240.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="199.27.128.0" subnetMask="255.255.248.0" />
    
    0 讨论(0)
  • 2020-12-20 22:30

    Since Azure SDK 2.3 it's possible to use Access Control List (ACL) to apply IP restrictions for your cloud services.

    Just add the ACL to your ServiceConfiguration.Cloud.cscfg:

    <NetworkConfiguration>
        <AccessControls>
            <AccessControl name="test">
                <Rule action="permit" description="test" order="100" remoteSubnet="xxx.xxx.xxx.xxx/32" />
                <Rule action="deny" description="test" order="200" remoteSubnet="0.0.0.0/0" />
            </AccessControl>
        </AccessControls>
        <EndpointAcls>
            <EndpointAcl role="WebRoleName" endPoint="Endpoint1" accessControl="test" />
        </EndpointAcls>
    </NetworkConfiguration>
    
    0 讨论(0)
提交回复
热议问题