gpt4 book ai didi

Apache:限制对虚拟主机内特定源IP的访问

转载 作者:行者123 更新时间:2023-12-03 07:46:28 25 4
gpt4 key购买 nike

我在同一个 apache 服务器上有多个命名虚拟主机,对于其中一个虚拟主机,我需要确保只允许访问一组特定的 IP 地址。

请建议执行此操作的最佳方法。我已经查看了 mod_authz_hosts 模块,但看起来我无法在虚拟主机内执行此操作。

最佳答案

对于 Apache 2.4,您可以使用 Require IP directive 。因此,仅允许来自 192.168.0.0/24 网络的计算机(范围 192.168.0.0 - 192.168.0.255)

<VirtualHost *:80>
<Location />
Require ip 192.168.0.0/24
</Location>
...
</VirtualHost>

如果您只想让本地主机能够访问,那么有一个特殊的 Require local directive .

The local provider allows access to the server if any of the following conditions is true:

  • the client address matches 127.0.0.0/8
  • the client address is ::1
  • both the client and the server address of the connection are the same

This allows a convenient way to match connections that originate from the local host:

<VirtualHost *:80>
<Location />
Require local
</Location>
...
</VirtualHost>

关于Apache:限制对虚拟主机内特定源IP的访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19711716/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com