gzip on;
gzip_min_length 1k;
gzip_buffers 16 64k;
gzip_http_version 1.1;
gzip_comp_level 9;
gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary on;
只是打开 gzip on 和gzip——types 本人在centos系统下对js不能有效压缩,要加上最后的gzip_vary才能压缩js
隐藏版本号
在nginx配置文件的http标签内加入“server_tokens off; ”参数,也可以放大server标签和location标签中
或者在源代码中更改
src/core/nginx.h
12#define NGINX_VERSION "1.6.2" // 修改为想要的版本号如2.4.3
#define NGINX_VER "nginx/" 改为 Apache
src/http/ngx_http_header_filter_module.c
1static
char
ngx_http_server_string[] =
"Server:nginx"
//改为apache
src/http/ngx_http_special_response.c
12345678910111213static
u_char ngx_http_error_full_tail[] =
"
" NGINX_VER
""
CRLF
"
"
CRLF
"