搜索

此内容没有您所选择的语言版本。

2.2.5. Securing the Apache HTTP Server

download PDF
The Apache HTTP Server is one of the most stable and secure services that ships with Red Hat Enterprise Linux. A large number of options and techniques are available to secure the Apache HTTP Server — too numerous to delve into deeply here. The following section briefly explains good practices when running the Apache HTTP Server.
Always verify that any scripts running on the system work as intended before putting them into production. Also, ensure that only the root user has write permissions to any directory containing scripts or CGIs. To do this, run the following commands as the root user:
chown root <directory_name>
chmod 755 <directory_name>
System administrators should be careful when using the following configuration options (configured in /etc/httpd/conf/httpd.conf):
FollowSymLinks
This directive is enabled by default, so be sure to use caution when creating symbolic links to the document root of the Web server. For instance, it is a bad idea to provide a symbolic link to /.
Indexes
This directive is enabled by default, but may not be desirable. To prevent visitors from browsing files on the server, remove this directive.
UserDir
The UserDir directive is disabled by default because it can confirm the presence of a user account on the system. To enable user directory browsing on the server, use the following directives:
UserDir enabled
UserDir disabled root
These directives activate user directory browsing for all user directories other than /root/. To add users to the list of disabled accounts, add a space-delimited list of users on the UserDir disabled line.
ServerTokens
The ServerTokens directive controls the server response header field which is sent back to clients. It includes various information which can be customized using the following parameters:
  • ServerTokens Full (default option) — provides all available information (OS type and used modules), for example:
    Apache/2.0.41 (Unix) PHP/4.2.2 MyMod/1.2
  • ServerTokens Prod or ServerTokens ProductOnly — provides the following information:
    Apache
  • ServerTokens Major — provides the following information:
    Apache/2
    
  • ServerTokens Minor — provides the following information:
    Apache/2.0
  • ServerTokens Min or ServerTokens Minimal — provides the following information:
    Apache/2.0.41
  • ServerTokens OS — provides the following information:
    Apache/2.0.41 (Unix)
It is recommended to use the ServerTokens Prod option so that a possible attacker does not gain any valuable information about your system.

Important

Do not remove the IncludesNoExec directive. By default, the Server-Side Includes (SSI) module cannot execute commands. It is recommended that you do not change this setting unless absolutely necessary, as it could, potentially, enable an attacker to execute commands on the system.

Removing httpd Modules

In certain scenarios, it is beneficial to remove certain httpd modules to limit the functionality of the HTTP Server. To do so, simply comment out the entire line which loads the module you want to remove in the /etc/httpd/conf/httpd.conf file. For example, to remove the proxy module, comment out the following line by prepending it with a hash sign:
#LoadModule proxy_module modules/mod_proxy.so
Note that the /etc/httpd/conf.d/ directory contains configuration files which are used to load modules as well.

httpd and SELinux

For information regarding the Apache HTTP Server and SELinux, see the Managing Confined Services Guide.
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.