How to modify the Nginx software name and version number on the network to prevent hackers from attacking the server to collect data information

Change the source code to hide the Nginx software name and version number

① Modify 3 Nginx source files in turn

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

turn up

#define nginx_version      1006003

#define NGINX_VERSION "1.6.3" <-- Change to the version number to be displayed first

#define NGINX_VER "nginx/" NGINX_VERSION <-- Modify to the software name you want to display


#define NGINX_VAR "nginx" <-- Modify to the software name you want to display

#define NGX_OLDPID_EXT     ".oldbin"

change into

#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"

② Modify the second Nginx source file

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

turn up

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

## Modify nginx to the software name you want to display

change into

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

③ Modify the third file, it will control sensitive information when the website reports external errors

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

turn up

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

change into

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

## This paragraph will be displayed when the website reports an error to the outside world

turn up

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

## Modify nginx to the software name you want to display

change into

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

④ Compile the software after modification to make it effective. If it is installed software, you need to recompile Nginx and compile it once according to the previous compilation, configure the configuration, and start the service

After recompiling, you also need to kill the previous nginx service, and it will fail after startup.

final result

# 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/"

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


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324855570&siteId=291194637