浅谈nginx(隐藏版本篇)

发表于 2019-10-03  707 次阅读


nginx隐藏版本信息

环境:Centos 7.6 1810

需要用到的命令有:vim ,wget

需要修改的文件有nginx.h,ngx_http_header_filter_module.c,ngx_http_special_response.c

其中nginx.h位于nginx-1.16.1/src/core

其中ngx_http_header_filter_module.c,ngx_http_special_response.c  都位于nginx-1.16.1/src/http

第一步:

下载nginx 源码包

wget http://nginx.org/download/nginx-1.16.1.tar.gz

解压

tar zxvf nginx-1.16.1.tar.gz

修改nginx.h 并保存

vim nginx.h

#define nginx_version 999999     其中999999 可以修改
#define NGINX_VERSION "9.99.9"   其中9.99.9 可以修改
#define NGINX_VER "dfrain/" NGINX_VERSION   其中dfain可以修改

修改ngx_http_header_filter_module.c并保存

static u_char ngx_http_server_string[] = "Server: dfrain" CRLF; 其中dfrain 可以修改

修改ngx_http_special_response.c并保存

static u_char ngx_http_error_tail[] =
"<hr><center>dfrain</center>" CRLF  其中dfrain  可以修改
"</body>" CRLF
"</html>" CRLF

修改完成后并安装。

使用curl -I http://xxx.xxxx.xx 测试

HTTP/1.1 200 OK
Server: dfrain/9.99.9
Date: Thu, 03 Oct 2019 13:43:15 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Powered-By: PHP/7.3.5

其中server 即为修改成功

如何安装请参照浅谈nginx(部署篇)

本站文章基于国际协议BY-NA-SA 4.0协议共享;
如未特殊说明,本站文章皆为原创文章,请规范转载。

0