如何修改HTTP头部的APACHE标记,隐藏apache服务器标记

PHP/Apache/Nginx

我们知道apache返回的头部含有如下信息

HTTP/1.1 200 OK
Date: Fri, 09 Sep 2022 02:32:51 GMT
Server: Apache
Upgrade: h2,h2c
Connection: Upgrade, Keep-Alive
Keep-Alive: timeout=500, max=100
Transfer-Encoding: chunked
Content-Type: text/plain

这时,配置中是ServerTokens Prod,显示只有apache。

如果ServerTokens FULL,则上面的Server一栏会有详细的apache版本,操作系统平台,mod_模块名称,php版本等等。

现在的要求是想做到连apahce也不显示。常规的办法是要编译源码在ap_release.h中

define AP_SERVER_BASEVENDOR “Apache Software Foundation”

define AP_SERVER_BASEPROJECT “Apache HTTP Server”

define AP_SERVER_BASEPRODUCT “Apache”

define AP_SERVER_MAJORVERSION_NUMBER 2

define AP_SERVER_MINORVERSION_NUMBER 4

define AP_SERVER_PATCHLEVEL_NUMBER 47

define AP_SERVER_DEVBUILD_BOOLEAN 0

这个方法比较麻烦。

所以我想到一个办法,就是修改bin下面的libhttpd.dll,搜索“Apache/2.4.47 (Win64)” 。只能找到一处,然后修改那里的几个apache英文。

如上图,我把第三个apache改为了123456. 则显示如下。