标题检索
致 get the headers,如果在服务器上,这似乎可以正常工作(所有测试都在 Ubuntu 14.04 Trusty Tahr 上完成):
curl -v http://localhost:80/ | head
产生类似的东西:
< HTTP/1.1 200 OK
< Date: Mon, 25 Jan 2021 09:17:51 GMT
* Server Apache/2.4.7 (Ubuntu) is not blacklisted
< Server: Apache/2.4.7 (Ubuntu)
删除版本号
到remove the version number,编辑文件/etc/apache2/conf-enabled/security.conf并修改行:
-
ServerTokens OS 到 ServerTokens Prod
-
ServerSignature On 到 ServerSignature Off
然后重启 Apache:
sudo service apache2 restart
您现在应该得到如下响应:
< HTTP/1.1 200 OK
< Date: Mon, 25 Jan 2021 09:20:03 GMT
* Server Apache is not blacklisted
< Server: Apache
删除“Apache”一词
要彻底删除Apache这个词,首先是install ModSecurity:
sudo apt-get install libapache2-mod-security2
以下几行似乎不需要(启用模块并重新启动 Apache)但for reference:
sudo a2enmod security2
sudo service apache2 restart
检查模块是否启用:
apachectl -M | grep security
应该显示:
security2_module (shared)
然后虽然you can amend/etc/modsecurity/modsecurity.conf(通过重命名modsecurity.conf-recommended),而不是修改/etc/apache2/apache.conf其中seems easier (注意你可以使用任何你想要的名字,在这种情况下我只是使用了一个空格):
<IfModule security2_module>
SecRuleEngine on
ServerTokens Min
SecServerSignature " "
</IfModule>
(使用Min 而不是Full 还可以防止mod_fastcgi 等模块出现在空白服务器名称之后。)
然后重启Apache:
sudo service apache2 restart
最终检查
现在当你运行命令时:
curl -v http://localhost:80/ | head
你应该得到:
< HTTP/1.1 200 OK
< Date: Mon, 25 Jan 2021 09:31:11 GMT
* Server is not blacklisted
< Server: