我在etc / apache2.conf文件中添加了这两行,它隐藏了操作系统和apache版本。
ServerSignature Off
ServerTokens Prod
但毕竟我可以看到带有服务器名称的标题
Server Apache
如何隐藏此信息? 我正在使用Debian 7,apache v 2.2
由于
答案 0 :(得分:11)
Apache本身无法完全取消设置Server标头(甚至没有使用mod_headers)。
这是appears to be by design,正如Apache开发人员所讨论的那样。
使用ModSecurity有一种方法可以做到这一点,但我对此知之甚少。相反,这些人已经弄明白了:
https://unix.stackexchange.com/questions/124137/change-apache-httpd-server-http-header
我可以验证这是有效的,只是在Debian 7.6上试过。
修改强>
为apache安装mod安全性,然后将其添加到apache2.conf
。
<IfModule security2_module>
SecRuleEngine on
ServerTokens Full
SecServerSignature " "
</IfModule>
重新启动apache之后,Server标头将消失
答案 1 :(得分:1)
使黑客感到困惑,并猜测他正在使用哪种Linux操作系统或Apache的哪个版本。 您可以将Apache服务器名称更改为所需的任何名称。
对于Ubuntu 20.04:
$ sudo apt install apache2 -y
$ sudo systemctl start apache2
$ curl -I localhost
HTTP/1.1 200 OK
Date: Fri, 23 Oct 2020 01:31:44 GMT
Server: Apache/2.4.41 (Ubuntu)
$ sudo apt install libapache2-mod-security2
$ sudo a2enmod security2
$ sudo vim /etc/apache2/conf-available/security.conf
ServerTokens已满
关闭服务器签名
SecServerSignature Microsoft-IIS / 10.0
$ sudo systemctl restart apache2
$ curl -I localhost
HTTP/1.1 200 OK
Date: Fri, 23 Oct 2020 01:54:00 GMT
Server: Microsoft-IIS/10.0
如果SecServerSignature选项设置为SecServerSignature " "
这将完全隐藏apache服务器名称。
HTTP/1.1 200 OK
Date: Fri, 23 Oct 2020 02:39:50 GMT
Server:
答案 2 :(得分:0)
等同于添加:
Sub ExtractLogs(textfilename, logfilename)
'Const ForReading = 1, ForWriting = 2
Dim fso, FileIn, Fileout, strTmp, count, Data
Set fso = CreateObject("Scripting.FileSystemObject")
Set FileIn = fso.OpenTextFile(logfilename, 1)
Set Fileout = fso.CreateTextFile(file_path & textfilename, 2, True)
If Len(Hour(Time)) = 1 Then
Lasthour = "0" & Hour(Time) - 1
If (Len(Lasthour) > 2) Then Lasthour = "23"
Currenthour = "0" & Hour(Time)
Else
Lasthour = Hour(Time) - 1
Currenthour = Hour(Time)
End If
count = 0
Data = ""
Do Until FileIn.AtEndOfStream
strTmp = FileIn.ReadLine
If Len(strTmp) > 0 Then
If (InStr(1, strTmp, Date & " " & Lasthour, vbTextCompare) > 0) Then
'Fileout.writeLine
Fileout.writeLine Data & strTmp
count = 1
Data = ""
ElseIf (InStr(1, strTmp, Date & " " & Currenthour, vbTextCompare) > 0) Then
count = 2
End If
If (InStr(1, strTmp, Date & " " & Lasthour, vbTextCompare) < 1 And count = 1) Then
Data = Data & vbNewLine & strTmp
End If
End If
Loop
FileIn.Close
Fileout.Close
到文件:SecServerSignature " "