如何在没有mod_security的情况下更改Apache的'Server:'header?

How to change Apache's 'Server:' header without mod_security?

如何在没有 mod_security 的情况下更改 Apache 的 Server: header?

我不想使用 mod_security,因为我没有其他事情要做。这对我来说是无用的开销。

相反,我应该在 Apache 的源代码中更改什么?我通常使用从源代码编译的Apache。

我使用的是 Apache 2.4.46 版。

要更改 Apache 的 Server: header,请在源代码中更改以下内容:

更改文件/path/to/httpd-2.4.46/include/ap_release.h:

转到如下行:

...
#define AP_SERVER_BASEPROJECT "Apache HTTP Server"
#define AP_SERVER_BASEPRODUCT "Apache"
...

并将其更改为任何内容,例如:

...
#define AP_SERVER_BASEPROJECT "Apache Something My Server"
#define AP_SERVER_BASEPRODUCT "Apache My Server"
...

然后编译apache,就可以了!

此外,请确保遵循随附的许可证。这里关于许可证的问题是 off-topic.