宝塔用户_amisnc 发表于 2025-5-23 22:33:44

【已解答】网站响应相关设置防护 Server: Apache

Rocky 9.5宝塔 9.6.0Apache 2.4.62PHP 8.2.27
架设的网站 不管是原生PHP 站 或者带框架网站



响应里面都带 Server: Apache怎么设置都没用 去除不掉

网站配置文件里面设置了相关   

# 正确配置 Header 指令
    <IfModule mod_headers.c>
      Header always set Server "WebServer"
      Header always unset Server
    </IfModule>
以及 Apache配置文件里面设置了   

# 彻底禁止Apache发送Server头
ServerTokens Prod
ServerSignature Off
TraceEnable Off

或者

<IfModule mod_headers.c>    Header always set Server "WebServer"    Header always unset Server    RequestHeader unset Server</IfModule>
各种办法都测试了 就是去除不掉


HTTP/1.1 200 OK
Date: Fri, 23 May 2025 14:21:23 GMT
Server: Apache
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: ZDEDebuggerPresent=php,phtml,php3; path=/
Set-Cookie: my_app_session=4lg9abmabd8a5kvnh5j249h8a6; expires=Fri, 23-May-2025 14:51:23 GMT; path=/; HttpOnly
Upgrade: h2,h2c
Connection: Upgrade, Keep-Alive
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 7794
Keep-Alive: timeout=5, max=1000
Content-Type: text/html

阿珂 发表于 2025-5-24 11:20:07

这种需要重新编译apache
可以参考以下方法,卸载apache,编辑脚本文件/www/server/panel/install/apache.sh
在编译前面添加下面内容: cd include
    sed -i 's/^#define AP_SERVER_BASEVENDOR .*/#define AP_SERVER_BASEVENDOR   "CustomVendor"/' ap_release.h
    sed -i 's/^#define AP_SERVER_BASEPROJECT .*/#define AP_SERVER_BASEPROJECT"WebServer"/' ap_release.h
    sed -i 's/^#define AP_SERVER_BASEPRODUCT .*/#define AP_SERVER_BASEPRODUCT"WebServer"/' ap_release.h
    cd ..终端执行安装命令:
bash /www/server/panel/install/apache.sh install 24


页: [1]
查看完整版本: 【已解答】网站响应相关设置防护 Server: Apache