流行服务器软件(nginx apache)隐藏响应头等信息的方法

发布时间:2020-06-13编辑:脚本学堂
在Lighttpd、Nginx 、Apache中隐藏响应头信息、Server信息、版本信息的方法,供大家学习参考。web server避免一些不必要的麻烦,可以把apache和php的版本信息不显示。

4. Apache 2.2.11
server/core.c:2784 添加:
ap_add_version_component(pconf, "jufukeji");
return;
输出 Header:
HTTP/1.1 200 OK
Date: Mon, 12 Jan 2009 14:28:10 GMT
Server: jufukeji
Last-Modified: Sat, 20 Nov 2004 20:16:24 GMT
ETag: "1920edd-2c-3e9564c23b600"
Accept-Ranges: bytes
Content-Length: 44
Content-Type: text/html

5. Squid 3.0 STABLE 11
src/globals.cc:58 改为:
const char *const full_appname_string = "jufukeji";
输出 Header:
HTTP/1.0 400 Bad Request
Server: jufukeji
Mime-Version: 1.0
Date: Mon, 12 Jan 2009 15:25:15 GMT
Content-Type: text/html
Content-Length: 1553
Expires: Mon, 12 Jan 2009 15:25:15 GMT
X-Squid-Error: ERR_INVALID_URL 0
X-Cache: MISS from 'cache.hutuworm.org'
Via: 1.0 'cache.hutuworm.org' (jufukeji)
Proxy-Connection: close

6. tomcat 6.0.18
java/org/apache/coyote/http11/Constants.java:56 和 java/org/apache/coyote/ajp/Constants.java:236 均改为:
ByteChunk.convertToBytes("Server: jufukeji" + CRLF);
输出 Header:
HTTP/1.1 200 OK
Server: jufukeji
ETag: W/"7857-1216684872000"
Last-Modified: Tue, 22 Jul 2008 00:01:12 GMT
Content-Type: text/html
Content-Length: 7857
Date: Mon, 12 Jan 2009 16:30:44 GMT

7. JBoss 5.0.0 GA
a. tomcat/src/resources/web.xml:40 改为
jufukeji
b. 下载 JBoss Web Server 2.1.1.GA srctar (http://www.jboss.org/jbossweb/downloads/jboss-web/)
java/org/apache/coyote/http11/Constants.java:56 和 java/org/apache/coyote/ajp/Constants.java:236 均改为:
ByteChunk.convertToBytes("Server: jufukeji" + CRLF);
将编译所得 jbossweb.jar 覆盖 JBoss 编译输出文件:
JBOSS_SRC/build/output/jboss-5.0.0.GA/server/all/deploy/jbossweb.sar/jbossweb.jar
JBOSS_SRC/build/output/jboss-5.0.0.GA/server/standard/deploy/jbossweb.sar/jbossweb.jar
JBOSS_SRC/build/output/jboss-5.0.0.GA/server/default/deploy/jbossweb.sar/jbossweb.jar
JBOSS_SRC/build/output/jboss-5.0.0.GA/server/web/deploy/jbossweb.sar/jbossweb.jar
输出 Header:
HTTP/1.1 200 OK
Server: jufukeji
X-Powered-By: jufukeji
Accept-Ranges: bytes
ETag: W/"1581-1231842222000"
Last-Modified: Tue, 13 Jan 2009 10:23:42 GMT
Content-Type: text/html
Content-Length: 1581
Date: Tue, 13 Jan 2009 10:30:42 GM

本文转自:http://wangwei007.blog.51cto.com/68019/600113