1. Reduce nginx compiled file size (reduce file size of Nginx)
The default nginx compilation option is in debug mode (-G) (debug mode inserts a lot of trace and assert), and a nginx has several megabytes after compiling. Remove Nginx debug mode compilation, after compiling only hundreds of K
In AUTO/CC/GCC, the last lines are:
# Debug
Cflags= "$CFLAGS-G"
Comment out or delete these lines and recompile.
2. Modify Nginx Header Camouflage Server
1) Modify Nginx.h
#vi nginx-0.7.30/src/core/nginx.h
#define NGINX_VERSION "1.8"
#define Nginx_ver "ltws/" nginx_version
#define NGINX_VAR "NGINX"
#define NGX_OLDPID_EXT ". Oldbin"
2) Modify Nginx_http_header_filter_module
#vi nginx-0.7.30/src/http/ngx_http_header_filter_module.c
will be as follows
static char ngx_http_server_string[] = "Server:nginx" CRLF;
Amended to
static char ngx_http_server_string[] = "Server:ltws" CRLF;
A) Modification of nginx_http_header_filter_module
#vi nginx-0.7.30/src/http/ngx_http_special_response.c
will be as follows:
Static U_char ngx_http_error_full_tail[] =
"<hr><center>" Nginx_ver "</center>" CRLF
"</body>" CRLF
"</html>" CRLF
;
Static U_char ngx_http_error_tail[] =
"<hr><center>nginx</center>" CRLF
"</body>" CRLF
"</html>" CRLF
;
Modified to:
Static U_char ngx_http_error_full_tail[] =
"<center>" Nginx_ver "</center>" CRLF
"<hr><center>http://www.linuxtone.org</center>" CRLF
"</body>" CRLF
"</html>" CRLF
;
Static U_char ngx_http_error_tail[] =
"<hr><center>LTWS</center>" CRLF
"</body>" CRLF
"</html>" CRLF
;
Revise and recompile the environment,
Display an effect chart (if no error page is specified) when 404 is wrong:
Using the Curl command to view server headers