Hide the real server information of Apache or nginx in the http request header

The method of hiding Apache:
Change the source code of Apache, and then recompile and install. The source code information that needs to be changed is as follows: In the
include directory --> ap_release.h file
#define AP_SERVER_BASEVENDOR "Apache Software Foundation"
#define AP_SERVER_BASEPROJECT "Apache HTTP Server"
#define AP_SERVER_BASEPRODUCT "Apache"

#define AP_SERVER_MAJORVERSION_NUMBER 2
#define AP_SERVER_MINORVERSION_NUMBER 4
#define AP_SERVER_PATCHLEVEL_NUMBER   25
#define AP_SERVER_DEVBUILD_BOOLEAN    0



The method of hiding Nginx:
change the source code of Nginx, then recompile and install, the source code information that needs to be changed is as follows:
src/http directory --> ngx_http_header_filter_module.c file
static u_char ngx_http_server_string[] = "Server: nginx" CRLF;
static u_char ngx_http_server_full_string[] = "Server: " NGINX_VER CRLF;
static u_char ngx_http_server_build_string[] = "Server: " NGINX_VER_BUILD CRLF;

Under the src/core directory -->nginx.h file
/*
 * Copyright (C) Igor Sysoev
 * Copyright (C) Nginx, Inc.
 */


#ifndef _NGINX_H_INCLUDED_
#define _NGINX_H_INCLUDED_


#define nginx_version      1013003
#define NGINX_VERSION      "1.13.3"
#define NGINX_VER          "nginx/" NGINX_VERSION

#ifdef NGX_BUILD
#define NGINX_VER_BUILD    NGINX_VER " (" NGX_BUILD ")"
#else
#define NGINX_VER_BUILD    NGINX_VER
#endif

#define NGINX_VAR          "NGINX"
#define NGX_OLDPID_EXT     ".oldbin"


#endif /* _NGINX_H_INCLUDED_ */


The version number of nginx can also be hidden without changing the source code. Add server_tokens off to the http category in the configuration file nginx.conf; the version number can be hidden, and it needs to be restarted to take effect after modification.

Guess you like

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