您的位置:首页 > 运维架构 > Nginx

关于nginx 配置gzip 压缩js问题 请求合并问题

2016-03-07 17:55 721 查看
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
src/http/ngx_http_header_filter_module.c
src/http/ngx_http_special_response.c
[/code]

安装nginx concat

12345678910# cd /usr/local/src/# wget http://nginx.org/download/nginx-1.4.2.tar.gz# wget https://github.com/alibaba/nginx-http-concat/archive/master.zip -O nginx-http-concat-master.zip# unzip nginx-http-concat-master.zip# tar -xzvf nginx-1.4.2.tar.gz# cd nginx-1.4.2# ./configure --prefix=/usr/local/nginx-1.4.2 --with-http_stub_status_module \--add-module=../nginx-http-concat-master# make# make install

配置nginx

123456789101112server { listen 80; server_name www.ttlsa.com; root /data/site/www.ttlsa.com; location /static/ { concat on; concat_max_files 20; concat_unique off; }}

URL访问控制来就应该只是资源文件,禁止指定扩展名程序被执行,例如:.php,.sh,.pl,nginx下禁止访问资源目录下的php程序文件
限制使用网站ip访问网站
图片及目录防盗链
优雅的错误提示
爬虫优化,可以进行适当限速使用tmpfs文件系统给/tmp提高效率,部分程序切图片操作临时放到/tmp下,可以把tmp设置成内存文件系统,占用内存空间的,就是从内存里拿出一块来当磁盘用
防DOS攻击限制单个ip的 req/s , conn
访问控制 allow/deny
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: