Nginx去除版本号
2016-01-08 14:59
609 查看
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
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
相关文章推荐
- Nginx -- Gzip 压缩功能作用
- nginx 服务器重启命令,关闭 (转)
- centos-6.6安装nginx-1.9.7和php7.0.0(一)
- Nginx + CGI/FastCGI + C/Cpp
- windows php7+nginx配置
- 【转载】一淘技术专家王晓哲:Nginx_lua的测试及选择
- Nginx-关键概念解读
- 一些nginx配置
- Nginx的accept_mutex配置分析
- nginx的yum源
- 我与nginx的初次见面
- Apache与Nginx的优缺点比较
- Nginx入门之静态资源与动态访问分离
- Nginx入门之负载均衡
- nginx初探
- Nginx 进程模型及事件处理机制
- Nginx 1.9 安装 ngx_pagespeed 模块
- nginx配置防盗链
- 统计5分钟内Nginx访问量及平均相应时间
- CentOS+nginx+uwsgi+Python+django 环境搭建