防黑客攻击服务器搜集数据信息,如何在网络上修改Nginx软件名与版本号

更改源码隐藏Nginx软件名及版本号

①  依次修改3个Nginx源码文件

# vim /usr/local/src/nginx-1.6.3/src/core/nginx.h

找到

#define nginx_version      1006003

#define NGINX_VERSION      "1.6.3"                          <-- 修改为先要显示的版本号

#define NGINX_VER          "nginx/" NGINX_VERSION    <-- 修改为想要显示的软件名


#define NGINX_VAR          "nginx"               <-- 修改为想要显示的软件名

#define NGX_OLDPID_EXT     ".oldbin"

修改为

#define nginx_version      1006003

#define NGINX_VERSION      "2.2.23"

#define NGINX_VER          "OWS/" NGINX_VERSION


#define NGINX_VAR          "OWS"

#define NGX_OLDPID_EXT     ".oldbin"

② 修改第二个Nginx源码文件

# vim /usr/local/src/nginx-1.6.3/src/http/ngx_http_header_filter_module.c

找到

49 static char ngx_http_server_string[] = "Server: nginx" CRLF;

## 将 nginx 修改为想要显示的软件名

修改为

49 static char ngx_http_server_string[] = "Server: OWS" CRLF;

③ 修改第三个文件,在网站对外报错时,它会控制敏感信息

# vim /usr/local/src/nginx-1.6.3/src/http/ngx_http_special_response.c

找到

"<hr><center>" NGINX_VER "</center>" CRLF

修改为

"<hr><center>" NGINX_VER " ([email protected])</center>" CRLF

## 当网站对外报错时会显示此段内容

找到

"<hr><center>nginx</center>" CRLF

## 将 nginx 修改为想要显示的软件名

修改为

"<hr><center>OWS</center>" CRLF

④ 修改后编译软件使其生效,如果是以安装好的软件,需要重新编译Nginx按之前的编译在编译一次,配置好配置,启动服务

在重新编译后还需要将之前的nginx服务杀死,在启动方能失效

最后结果

# curl -I www.123.org

HTTP/1.1 200 OK

Server: OWS

Date: Tue, 24 Apr 2018 14:59:04 GMT

Content-Type: text/html; charset=UTF-8

Connection: keep-alive

X-Powered-By: PHP/5.3.27

Link: <http://www.123.org/wp-json/>; rel="https://api.w.org/"

之前配置了隐藏版本号,所以不显示版本


猜你喜欢

转载自blog.51cto.com/13673885/2107243