您的位置:首页 > 运维架构 > Nginx

nginx安全优化之隐藏版本

2016-04-28 11:03 686 查看
安全一直是互联网不可忽视的问题,今天介绍下nginx隐藏版本,别人不清楚你的版本,就无法使用针对nginx的漏洞进行***。nginx软件是开源的但是源码中也携带版本信息,可以修改源代码进行隐藏版本信息。
版本显示[root@evanlinux ~]# curl -I 192.168.1.7|grep Server Server: nginx/1.8.1 #nginx的软件版本信息
51CTO的web容器版本[root@evanlinux nginx-1.8.1]# curl -I www.51cto.com|grep ServerServer: Tengine #隐藏了版本信息隐藏了版本,让版本漏洞无法使用
修改nginx源代码来隐藏nginx版本信息文件1 "nginx-1.8.1/src/core/nginx.h" 12行-23行原配置文件[root@evanlinux tools]# sed -n '12,23p' nginx-1.8.1/src/core/nginx.h #define nginx_version 1008001#define NGINX_VERSION "1.8.1" #修改想要显示的版本如:2.2.23#define NGINX_VER "nginx/" NGINX_VERSION #将nginx修改成想要显示的软件名称#ifdef NGX_BUILD#define NGINX_VER_BUILD NGINX_VER " (" NGX_BUILD ")"#else#define NGINX_VER_BUILD NGINX_VER#endif
#define NGINX_VAR "NGINX" #将nginx修改成想要显示的软件名称(Evan Web Server)#define NGX_OLDPID_EXT ".oldbin"修改后[root@evanlinux tools]# sed -n '12,23p' nginx-1.8.1/src/core/nginx.h#define nginx_version 1008001#define NGINX_VERSION "2.2.23" #版本修改为2.2.23#define NGINX_VER "EWS/" NGINX_VERSION#nginx修改为EWS#ifdef NGX_BUILD#define NGINX_VER_BUILD NGINX_VER " (" NGX_BUILD ")"#else#define NGINX_VER_BUILD NGINX_VER#endif
#define NGINX_VAR "EWS" #nginx修改为EWS#define NGX_OLDPID_EXT ".oldbin"
文件2 "nginx-1.8.1/src/http/ngx_http_header_filter_module.c" 49行源文件[root@evanlinux tools]# sed -n '49p' nginx-1.8.1/src/http/ngx_http_header_filter_module.c static char ngx_http_server_string[] = "Server: nginx" CRLF; #将nginx修改为想要的版本修改后[root@evanlinux tools]# sed -n '49p' nginx-1.8.1/src/http/ngx_http_header_filter_module.c static char ngx_http_server_string[] = "Server: EWS" CRLF; #将nginx修改为了EWS
修改链接错误的版本显示错误链接网站显示

访问错误的链接也有暴露版本信息的危险
文件3 "nginx-1.8.1/src/http/ngx_http_special_response.c" 29行源文件[root@evanlinux tools]# sed -n '21,31p' nginx-1.8.1/src/http/ngx_http_special_response.c"<hr><center>nginx</center>" CRLF #将nginx修改为想要的版本信息修改后[root@evanlinux tools]# sed -n '29p' nginx-1.8.1/src/http/ngx_http_special_response.c "<hr><center>EWS</center>" CRLF
重新编译安装,可以看到如下效果编译安装方法:http://iywdd.blog.51cto.com/11177578/1767529
版本信息[root@evanlinux nginx-1.8.1]# curl -I 192.168.1.7HTTP/1.1 200 OKServer: EWS/2.2.23 #更改为EWS/2.2.23 Date: Thu, 07 Apr 2016 11:51:41 GMTContent-Type: text/htmlContent-Length: 612Last-Modified: Thu, 07 Apr 2016 11:50:40 GMTConnection: keep-aliveETag: "57064990-264"Accept-Ranges: bytes
错误链接修改后结果


访问错误的链接更改了版本信息本文出自 “运维地带” 博客,请务必保留此出处http://iywdd.blog.51cto.com/11177578/1767686
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  nginx