|
今天忽然想在搞搞nginx ,弄一个版本号隐藏吧! 算是一个安全的优化吧。注意这里是在编译之间要做的事。1、自己搭建了一个nginx的服务器,在curl的时候,有如下提示:
curl -I 10.0.0.231 (直接curl的是ip地址)
HTTP/1.1 500 Internal Server Error
Server: nginx/1.6.2
Date: Wed, 10 Sep 2014 02:53:18 GMT
Content-Type: text/html
Connection: keep-alive
X-Powered-By: PHP/5.3.27
##Server: nginx/1.6.2 此处直接赤裸裸的直接暴漏
2、nginx版本号隐藏:
vi nginx.conf 中的http标签
server_tokens off;
#这里控制response header 服务版本信息;错误信息中web服务版本信息显示;
3、查看
curl -I 10.0.0.231
HTTP/1.1 500 Internal Server Error
Server: nginx
Date: Wed, 10 Sep 2014 02:59:25 GMT
官方: http://nginx.org/en/docs/http/ngx_http_core_module.html#server_tokens
Syntax: | server_tokens on | off;
| Default: | server_tokens on; | Context: | http, server, location
| Enables or disables emitting nginx version in error messages and in the“Server” response header field.
4、到安装目录下
pwd
/home/tools/nginx-1.6.2
cd src/http/
vim ngx_http_special_response.c
29 "<hr><center>apache</center>" CRLF
vim ngx_http_header_filter_module.c
49 static char ngx_http_server_string[] = "Server: Apache" CRLF;
50 static char ngx_http_server_full_string[] = "Server:Apache " NGINX_VER CRLF;
5、重新编译
/application/nginx1.6.2/sbin/nginx -V
查看编译信息
make && make install
6、再次 curl -I 10.0.0.231
HTTP/1.1 500 Internal Server Error
Server: apache
|
|