【问题标题】:How to limit web site access to USA only如何限制网站仅访问美国
【发布时间】:2016-11-15 22:57:35
【问题描述】:

如何使用 ASP Classic(Windows 服务器)限制我的网站仅访问美国。我阅读了有关 htaccess 的信息,但不确定如何将其实现为 ASP 经典编程语言。

【问题讨论】:

  • .htaccess 文件特定于 Apache 服务器,而 Classic ASP 仅在 IIS 上运行。无论如何,您需要阻止 IP 范围,这是您需要通过服务器防火墙设置而不是通过经典 ASP 进行的操作。这个问题值得一读stackoverflow.com/questions/2111246/…
  • 另外@John 将 IP 列入黑名单是一个糟糕的实现,因为它们很容易被欺骗。
  • 你将拥有 Netflix 的所有成功:即没有

标签: iis asp-classic


【解决方案1】:

您可以通过实现允许您设置 IP 范围的 IIS 模块(即Helicon Ape)来添加 htaccess 功能。这样的模块必须安装在您的 Windows 网络服务器(Server 2008 及更高版本)上,并将在您的 IIS 管理器中进行配置。完成此操作后,您就可以以与在 Apache 服务器上几乎相同的方式使用 htaccess。

另一种(理论上的)方法是对远程 IP 地址进行服务器端检查。

首先您需要检索远程 IP 地址

remote_addr = Request.ServerVariables("REMOTE_ADDR");

然后您可以与给定的范围进行比较

function compareIps(ip, lowrange, highrange)
   dim octetIPArray(4) as integer, octetIPLowArray(4) as integer, octetIPHighArray(4) as integer
   compareIps = False
   octetArray = split(ip, '.', -1, vbtextcompare)
   octetIPLowArray = split(lowrange, '.', -1, vbtextcompare)
   octetIPHighArray = split(highrange, '.', -1, vbtextcompare)

   for i = 0 to 3
      if octetArray(i) >= octetIPLowArray(i) and octetArray(i) <= octetIPHighArray(i) then
         compareIps = True
         exit function
      end if
   next
    end function

if compareIps(remote_addr, "3.0.0.0","3.255.255.255")=True then
   response.end
end if

请注意,在美国 IP 流量的情况下,有 quite a few ranges 要阻止(接近 7.000)。

如前所述,IP 可以被欺骗,所以这根本不是 100% 安全的方法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-01-13
    • 1970-01-01
    • 2018-07-13
    • 1970-01-01
    • 1970-01-01
    • 2013-11-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多