设置gzip
nginx.conf文件
http {
.........
# gzip setting
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
#gzip_http_version 1.0;
gzip_comp_level 3;
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 off;
gzip_disable "MSIE [1-6]\.";
.........
}
测试
curl -I -H "Accept-Encoding: gzip, deflate" "http://www.mfbuluo.com/images/beijing.jpg"
curl -I -H "Accept-Encoding: gzip, deflate" "http://www.mfbuluo.com/css/index.css"
curl -I -H "Accept-Encoding: gzip, deflate" "http://www.mfbuluo.com/app/index.html"
结果
HTTP/1.1 404 Not Found
Server: nginx
Date: Wed, 01 Mar 2017 08:02:33 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
X-Powered-By: PHP/5.6.25
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Cache-Control: no-cache, must-revalidate, max-age=0
Pragma: no-cache
Link: <http://www.mfbuluo.com/wp-json/>; rel="https://api.w.org/"
Content-Encoding: gzip
中文乱码:
开启https和优化
1,注释掉默认的server设置块;
2,开启https的设置块
开启https 同时支持http 访问
设置反向代理tomcat:
设置动静分离
1,nginx和tomcat指向同一个目录