解惑

解己之惑,解人之惑

隐藏Apache2的服务器信息

其实最近半年主要在搞安全方面的东西,所以把工作中的知识在这里也应用下,首先强化服务器的安全,对外提供的HTTP服务不要返回服务器太多的信息,默认情况下会返回很多信息,例如服务器的OS是什么,HTTP服务器是什么,版本,有了这个信息服务器又没有及时打安全补丁的情况下,黑客就很容易根据这些信息有针对性的对服务器的漏洞进行攻击了,所以第一步隐藏这个信息,其实原来我也搞过,不过那个是针对apache的,现在变成2了,配置文件的位置有所变化:/etc/apache2/conf-available/security.conf:

ServerTokens Prod

ServerSignature Off

顺便看到了其它的一些安全选项被注释掉了,打开注释:

Header set X-Content-Type-Options: “nosniff”

Header set X-Frame-Options: “sameorigin”

重启后报错:

AH00526: Syntax error on line 63 of /etc/apache2/conf-enabled/security.conf

Invalid command ‘Header’, perhaps misspelled or defined by a module not included in the server configuration

其实从那两个选项的说明中已经提示原因了:

#
# Setting this header will prevent other sites from embedding pages from this
# site as frames. This defends against clickjacking attacks.
# Requires mod_headers to be enabled.
#

sudo a2enmod headers

再次重启就没有问题。

BTW,那两个Header的选项分别是防MIME嗅探和钓鱼的。

(Visited 291 times, 1 visits today)

1 Comment

  1. 听说评论有问题,来试试

发表评论

邮箱地址不会被公开。 必填项已用*标注

© 2024 解惑

本主题由Anders Noren提供向上 ↑