修改nginx名称与版本号

2017-11-26 · xiejiahe

注意:需要在编译之前修改

版本号:1.10.2

下载Linux nginx 1.10.2稳定版

点击此处下载


怎么查看一个网站是什么服务器?

可以在本博客直接按F12在NETWORK里面点击第一个找到Response Headers

Accept-Ranges:bytes
Cache-Control:public, max-age=0
Connection:keep-alive
Content-Encoding:gzip
Content-Type:text/html; charset=UTF-8
Date:Sun, 26 Nov 2017 01:11:24 GMT
ETag:W/"796-15fcf3290e8"
Last-Modified:Sat, 18 Nov 2017 12:55:18 GMT
# 服务器名称和版本号
Server:nginx/1.10.2
Transfer-Encoding:chunked
Vary:Accept-Encoding

修改src/core/nginx.conf

修改之前

#define NGINX_VERSION      "1.10.2"
#define NGINX_VER          "nginx/" NGINX_VERSION

修改之后

#define NGINX_VERSION      "6.6.6"
#define NGINX_VER          "hello/" NGINX_VERSION

修改/src/http/ngx_http_header_filter_module.c

用来修改响应头 Response Headers 修改之前

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

修改之后

static char ngx_http_server_string[] = "Server: hello" CRLF;
static char ngx_http_server_full_string[] = "Server: " NGINX_VER CRLF;

修改/src/http/ngx_http_special_response.c

用来修改错误页 修改之前

static u_char ngx_http_error_tail[] =
"<hr><center>nginx</center>" CRLF
"</body>" CRLF
"</html>" CRLF
;

修改之后

static u_char ngx_http_error_tail[] =
"<hr><center>hello</center>" CRLF
"</body>" CRLF
"</html>" CRLF
;

至此已经完成

WEB安全服务器
原创文章,转载请注明出处。