为什么httpd中有Require,但是还需要Allow?

为什么httpd中有Require,但是还需要Allow?

我们有 Require 和 Allow 指令,可以在 httpd.conf 中使用。

不起作用Require ip addressAllow from address ; Deny from all

正如我们所看到的本文档mod_access_compat 提供的、AllowDenyOrder指令已弃用,并将在将来的版本中消失。您应避免使用它们,并避免使用推荐使用它们的过时教程。

为什么我们仍然需要允许?

答案1

如果您使用的是 Apache httpd 2.2,那么您将使用 allow 和 denied(order/satisfy 也是如此)。如果您使用的是 Apache httpd 2.4,那么您将使用 Require。

事实上,mod_authz_host 在 2.2 和 2.4 之间被重写,旧的 Deny/Allow 行为现已弃用。它仍然通过 mod_access_compat 实现,但我发现这个模块大多数时候都没有启用。

新的 mod_authz_host 可以简化访问控制。您可以在此处查看一些示例:http://httpd.apache.org/docs/2.4/upgrading.html#run-time

2.2 configuration:

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

2.4 configuration:

Require host example.org

Allow/Deny/Satisfy/Order 不应再使用,通常很容易将它们转换为 Require。

相关内容