Nginx Simple optimization

Source: Internet
Author: User
Keywords Nginx
Tags compiled compiling debug default file file size gcc html

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.