location ~ .*\.(jpg|gif|png)$ { gzip on(开启); gzip_http_version 1.1(版本); gzip_comp_level 2(压缩比); gzip_types(文件类型) text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png; root /opt/app/code/images; }
location ~ ^/download { gzip_static on(开启); tcp_nopush on; root /opt/app/code; }
location ~ .*\.(htm|html)$ { add_header Access-Control-Allow-Origin(跨域访问的请求域名) *(表示所有); add_header Access-Control-Allow-Methods(跨域访问的请求方法) GET,POST,PUT,DELETE,OPTIONS; expires 24h(缓存周期); root /opt/app/code; }
原文:https://www.cnblogs.com/yoyo1216/p/10935408.html