从 2.2 升级到 2.4

为了帮助人们进行升级,我们维护了一个文档,该文档描述了对现有 Apache HTTP Server 用户至关重要的信息。这些只是简要说明,您应该能够在New Features文档或src/CHANGES文件中找到更多信息。应用程序和模块开发人员可以在API updates概述中找到 API 更改的摘要。

本文档描述了服务器行为的更改,这些更改可能需要您更改配置或使用服务器的方式,以便 continue 使用 2.4(如当前使用的 2.2)。要利用 2.4 中的新功能,请参阅“新功能”文档。

本文仅描述从 2.2 到 2.4 的更改。如果您要从 2.0 版升级,则还应咨询2 .0 到 2.2 升级文档。

编译时配置更改

编译过程与 2.2 版中使用的过程非常相似。在大多数情况下,可以使用旧的configure命令行(在已安装的服务器目录的build/config.nice中找到)。默认设置中有一些更改。更改的一些细节:

运行时配置更改

授权配置中已进行了重大更改,而其他一些次要配置更改也可能需要更改 2.2 配置文件,然后才能将其用于 2.4.

Authorization

使用授权的任何配置文件都可能需要更改。

您应该查看身份验证,授权和访问控制方法,尤其是超越授权部分,该部分解释了用于控制应用授权指令 Sequences 的新机制。

删除了控制授权模块在与身份验证的用户不匹配时如何响应的指令:这包括 AuthzLDAPAuthoritative,AuthzDBDAuthoritative,AuthzDBMAuthoritative,AuthzGroupFileAuthoritative,AuthzUserAuthoritative 和 AuthzOwnerAuthoritative。这些指令已被更具表现力的RequireAnyRequireNoneRequireAll代替。

如果使用mod_authz_dbm,则必须移植配置以使用Require dbm-group ...代替Require group ...

Access control

在 2.2 中,使用指令OrderAllowDenySatisfy进行了基于 Client 端主机名,IP 地址和其他 Client 端请求 Feature 的访问控制。

在 2.4 中,使用新模块mod_authz_host以与其他授权检查相同的方式完成这种访问控制。尽管为了与旧配置兼容,提供了新的模块mod_access_compat,但旧的访问控制习惯用法应替换为新的身份验证机制。

Mixing old and new directives

从技术上讲,可以将OrderAllowDeny之类的旧指令与Require之类的新指令混合使用,但不建议这样做。创建mod_access_compat是为了支持仅包含旧指令的配置,以促进 2.4 升级。请检查以下示例,以更好地了解可能出现的问题。

以下是执行相同访问控制的旧方法和新方法的一些示例。

在此示例中,没有身份验证,并且所有请求都被拒绝。

2.2 configuration:

Order deny,allow
Deny from all

2.4 configuration:

Require all denied

在此示例中,没有身份验证,并且所有请求都被允许。

2.2 configuration:

Order allow,deny
Allow from all

2.4 configuration:

Require all granted

在以下示例中,不进行身份验证,并且 example.org 域中的所有主机都被允许访问;所有其他主机都被拒绝访问。

2.2 configuration:

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

2.4 configuration:

Require host example.org

在以下示例中,将新旧指令混合使用会导致意外结果。

混合新旧指令:不能按预期工作

DocumentRoot "/var/www/html"

<Directory "/">
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

<Location "/server-status">
    SetHandler server-status
    Require local
</Location>

access.log - GET /server-status 403 127.0.0.1
error.log - AH01797: client denied by server configuration: /var/www/html/server-status

为什么 httpd 即使配置似乎允许它也拒绝访问服务器状态?因为在此配置merge方案中,mod_access_compat指令优先于mod_authz_host

相反,此示例按预期工作:

新旧指令混合使用:按预期工作

DocumentRoot "/var/www/html"

<Directory "/">
    AllowOverride None
    Require all denied
</Directory>

<Location "/server-status">
    SetHandler server-status
    Order deny,allow
    Deny from all
    Allow From 127.0.0.1
</Location>

access.log - GET /server-status 200 127.0.0.1

因此,即使仍然可以使用混合配置,请在升级时尽量避免使用它:保留旧的指令,然后在以后迁移到新的指令,或者只是批量迁移所有内容。

在许多带有身份验证的配置中,其中Satisfy的值为默认值* ALL *,省略了仅禁用基于主机的访问控制的代码段:

2.2 configuration:

# 2.2 config that disables host-based access control and uses only authentication
Order Deny,Allow
Allow from all
AuthType Basic
AuthBasicProvider file
AuthUserFile /example.com/conf/users.passwd
AuthName secure
Require valid-user

2.4 configuration:

# No replacement of disabling host-based access control needed
AuthType Basic
AuthBasicProvider file
AuthUserFile /example.com/conf/users.passwd
AuthName secure
Require valid-user

在将身份验证和访问控制都有意义地结合在一起的配置中,应该迁移访问控制指令。此示例允许满足以下两个条件的请求:

2.2 configuration:

Order allow,deny
Deny from all
# Satisfy ALL is the default
Satisfy ALL
Allow from 127.0.0.1
AuthType Basic
AuthBasicProvider file
AuthUserFile /example.com/conf/users.passwd
AuthName secure
Require valid-user

2.4 configuration:

AuthType Basic
AuthBasicProvider file
AuthUserFile /example.com/conf/users.passwd
AuthName secure
<RequireAll>
  Require valid-user
  Require ip 127.0.0.1
</RequireAll>

在将身份验证和访问控制都有意义地结合在一起的配置中,应该迁移访问控制指令。本示例允许符合以下两个条件的请求:

2.2 configuration:

Order allow,deny
Deny from all
Satisfy any
Allow from 127.0.0.1
AuthType Basic
AuthBasicProvider file
AuthUserFile /example.com/conf/users.passwd
AuthName secure
Require valid-user

2.4 configuration:

AuthType Basic
AuthBasicProvider file
AuthUserFile /example.com/conf/users.passwd
AuthName secure
# Implicitly <RequireAny>
Require valid-user
Require ip 127.0.0.1

其他配置更改

如下所述,某些其他小的调整对于特定配置可能是必需的。

Misc Changes

第三方模块

加载之前,所有模块都必须重新编译为 2.4.

否则,为版本 2.2 设计的许多第三方模块将与 Apache HTTP Server 版本 2.4 保持不变。有些将需要更改;请参阅API update概述。

升级时的常见问题

首页