Can I restrict who accesses my Azure website to people in the US?

喜欢而已 提交于 2021-01-28 08:51:22

问题


I want to limit the people who can see and visit my website to only those in the US! I know I can restrict IP addresses to only those I give in my web.config file. Is there some subnet mask or something I can use below to define all US ip addresses or is there some Azure settings I can configure in the Azure portal?

ex.

<system.webServer>
  <security>
    <ipSecurity allowUnlisted="false" denyAction="NotFound">
      <add allowed="true" ipAddress="24.130.112.11" subnetMask="255.255.0.0" />
      <add allowed="true" ipAddress="73.92.189.234" subnetMask="255.255.0.0" />
    </ipSecurity>
  </security>

回答1:


There is no Azure setting you can configure in the Azure portal to restrict access based on IP address from any region.

I suggest you could use some nuget package such as MaxMind.GeoIP2 which can provide GeoIP lookup functionality to get the location information such as country and city based on the client IP address.

This way would be better than having to find out and whitelist all the IP addresses range and subnet masks for U.S.




回答2:


As far as I know, that is the only way to restrict IP addressees in Azure. You can also use IP Restrictions menu in Azure app services to add or remove restrictions.

However, I would argue that the approach to limiting users who can access your site by region (IP address) is not the correct solution. It seems like an unnecessary complication that can run into both technical and logical issues. Would you want someone who works in San Francisco but works outside of the city to only be able to access your site when they are in the office?

I think there are a handful of more appropriate and easier to manage solutions such as:

  • Prompting the user (if they have never visited your site before) with a message saying the site is in test/alpha/beta and is only intended for X users (English speaking, metropolitan workers, etc.)
  • Ask for information on login that matches your description (language, region, location, etc.) and either redirect them to the correct location or have them gracefully leave the site
  • Distribute beta keys to anyone you want to access your site. You can be very specific about who you invite especially if you have a certain demographic in mind, which may prove more valuable than simply having a very large pool of users.


来源:https://stackoverflow.com/questions/48590149/can-i-restrict-who-accesses-my-azure-website-to-people-in-the-us

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!