文章目录
- 1、修改请求响应头中的server信息
- 2、修改nginx返回的默认页面中的server信息
通过修改nginx源码来修改nginx返回的默认的server信息。
1、修改请求响应头中的server信息
修改前的代码和响应头中的server信息:
代码文件路径:nginx-1.21.4\src\http\ngx_http_header_filter_module.c
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;
修改后的代码和响应头中的server信息:
static u_char ngx_http_server_string[] = "Server: parasaga" CRLF;
static u_char ngx_http_server_full_string[] = "Server: parasaga" CRLF;
static u_char ngx_http_server_build_string[] = "Server: " NGINX_VER_BUILD CRLF;
2、修改nginx返回的默认页面中的server信息
修改前的代码和默认页面中的server信息:
代码文件路径:nginx-1.21.4\src\http\ngx_http_special_response.c
static u_char ngx_http_error_full_tail[] =
"<hr><center>" NGINX_VER "</center>" CRLF
"</body>" CRLF
"</html>" CRLF
;
static u_char ngx_http_error_build_tail[] =
"<hr><center>" NGINX_VER_BUILD "</center>" CRLF
"</body>" CRLF
"</html>" CRLF
;
static u_char ngx_http_error_tail[] =
"<hr><center>nginx</center>" CRLF
"</body>" CRLF
"</html>" CRLF
;
修改后的代码和默认页面中的server信息:
static u_char ngx_http_error_full_tail[] =
"<hr><center> parasaga </center>" CRLF
"</body>" CRLF
"</html>" CRLF
;
static u_char ngx_http_error_build_tail[] =
"<hr><center> parasaga </center>" CRLF
"</body>" CRLF
"</html>" CRLF
;
static u_char ngx_http_error_tail[] =
"<hr><center> parasaga </center>" CRLF
"</body>" CRLF
"</html>" CRLF
;