简体   繁体   中英

Azure restrict access to web app by ip range

I have deployed a node js web app on azure and I want to restrict access to it by ip address. I have done a similar thing easily before in AWS with security groups. However, I am at present on the free dev platform and when I got to the ip restrictions setting tab in the Azure portal gui it says I need to upscale the app because ip restriction is not available on the current platform. What I'm build needs very minimal resources. It is a one page internal static newsletter. What is the minimal resource on azure I need to use to get the ip restriction or is there another route I can use?

The minimal resource you need to configure IP restrictions within the Portal is B1 :

在此输入图像描述

Read here how to configure it: Azure App Service Static IP Restrictions


Note: You can also enable IP Restrictions on the free tier by adding a web.config using the IP Security setting. Working sample:

<configuration>
  <system.webServer>
    <security> 
        <ipSecurity allowUnlisted="false"> 
            <clear/> 
             <add ipAddress="83.116.19.53" allowed="true"/> 
        </ipSecurity>  
    </security>
</system.webServer> 
</configuration>

Now all you have to do is to put the web.config to your wwwroot directory. You can either include the web.config in your deployment or you manually add it using the Kudu engine.

Just replace <YOURSITE> with your actual site and follow the link:

https://<YOURSITE>.scm.azurewebsites.net/DebugConsole/?shell=powershell

在此输入图像描述

If you now browse the app using an unlisted IP you will get the following error:

You do not have permission to view this directory or page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM