我们如何获得基于 IP 的网站访问权限?

How can we get IP based website access?

我已经安装了 rockmongo,我只希望我可以通过 web.i 访问它已将此规则放入 .htaccess

order allow,deny
allow from 118.67.228.162
deny form all

但这否认包括 myself.It 在内的每个人之前都工作正常

前期见Access control by host

The Allow, Deny, and Order directives, provided by mod_access_compat, are deprecated and will go away in a future version. You should avoid using them, and avoid outdated tutorials recommending their use.

你的指令拒绝所有人,因为

Order Allow,Deny
Deny from all

请参阅 Order 了解说明

Allow,Deny
First, all Allow directives are evaluated; at least one must match, or the request is rejected. Next, all Deny directives are evaluated. If any matches, the request is rejected. Last, any requests which do not match an Allow or a Deny directive are denied by default.

如果您仍然想使用它,请参阅 Order

中的第一个示例

In the following example, all hosts in the example.org domain are allowed access; all other hosts are denied access.

Order Deny,Allow
Deny from all
Allow from example.org

对于特定的 IPv4 地址,这将是

Allow from 1.2.3.4

如果客户端使用 IPv6,则示例如下

Allow from 2001:db8:85a3::8a2e:370:7334

要找出合适的地址,请访问网站并查看 Apache 的 access.log 文件。在文件末尾,你会发现类似

的内容

1.2.3.4 - - [01/Jun/2016:10:10:58 +0200] "GET / HTTP/1.1" 403 492 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0"

当它是 IPv4 时,或

2001:db8:85a3::8a2e:370:7334 - - [01/Jun/2016:10:10:58 +0200] "GET / HTTP/1.1" 403 492 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0"

当它是 IPv6 地址时。