1.在配置文件中的 http节点中加入
server_tokens off;
2.更改源码隐藏nginx软件的名称
1). 查看Nginx编译的参数
/usr/local/nginx/sbin/nginx -V
###
--prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_stub_status_module --add-module=/soft/ngx_http_consistent_hash-master
###
2). 头信息的修改
vi /soft/nginx-1.6.0/src/http/ngx_http_header_filter_module.c
到这两行
49 static char ngx_http_server_string[] = "Server: nginx" CRLF;
50 static char ngx_http_server_full_string[] = "Server: " NGINX_VER CRLF;
修改为自已要想的一个名字
static char ngx_http_server_string[] = "Server: BWS" CRLF;
static char ngx_http_server_full_string[] = "Server: BWS" CRLF;
3). 修改错误页
vi /soft/nginx-1.6.0/src/http/ngx_http_special_response.c
28 static u_char ngx_http_error_tail[] =
29 "<hr><center>nginx</center>" CRLF
30 "</body>" CRLF
31 "</html>" CRLF
修改为:
static u_char ngx_http_error_tail[] =
"<hr><center>BWS</center>" CRLF
"</body>" CRLF
"</html>" CRLF
当然这里你也可以写一些简单的HTML标签来如:
static u_char ngx_http_error_tail[] =
"<hr><center><a href='http://xxx.xxx.com'>BWS</a></center>" CRLF
"</body>" CRLF
"</html>" CRLF
完成上述步骤后,编译
如查有安装Nginx就先停了 pkill nginx
然后编译安装
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_stub_status_module --add-module=/soft/ngx_http_consistent_hash-master
make && make install