且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

隐藏nginx,apache,tomcat,varnish版本信息

更新时间:2022-10-08 09:59:39

1.隐藏nginx的版本号和server信息

[root@node2 nginx-1.8.0]# vim src/http/ngx_http_special_response.c 

static u_char ngx_http_error_tail[] =

"<hr><center>tingyun</center>" CRLF       --修改定义的名字

"</body>" CRLF

"</html>" CRLF

[root@node2 nginx-1.8.0]# vim src/http/ngx_http_header_filter_module.c 

static char ngx_http_server_string[] = "Server: tingyun" CRLF;

[root@node2 nginx-1.8.0]# vim src/core/nginx.h 

#define NGINX_VERSION      ""

#define NGINX_VER          "tingyun/" NGINX_VERSION

#define NGINX_VAR          "tingyun"

[root@node2 nginx-1.8.0]# ./configure --prefix=/usr/local/nginx-1.8.0 --user=www --group=www --with-poll_module --with-threads --with-file-aio --with-http_sub_module --with-pcre=/usr/local/pcre-8.37 --with-http_stub_status_module   --编译

[root@node2 nginx-1.8.0]# make && make install

隐藏nginx,apache,tomcat,varnish版本信息


2.隐藏varnish的版本信息

[root@node2 varnish]# vim default.vcl        --添加如下内容

sub vcl_deliver {

    unset resp.http.Via;       --默认是显示版本信息(unset 是取消显示)

    unset resp.http.X-Varnish;

    set resp.http.Server="no-server";  --设置后端服务器版本信息(unset 就是取消)

}

[root@node2 varnish]# /etc/init.d/varnish restart

Stopping Varnish Cache:                                    [  OK  ]

Starting Varnish Cache:                                    [  OK  ]

[root@node2 varnish]#

隐藏nginx,apache,tomcat,varnish版本信息










本文转自 z597011036 51CTO博客,原文链接:http://blog.51cto.com/tongcheng/1714681,如需转载请自行联系原作者