nginx配置
2022-04-07 本文已影响0人
三省吾身_9862
开启gzip压缩
http {
# 开启gzip
gzip on;
# 启用gzip压缩的最小文件;小于设置值的文件将不会被压缩
gzip_min_length 1k;
# gzip 压缩级别 1-10
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;
# 是否在http header中添加Vary: Accept-Encoding,建议开启
gzip_vary on;
}
添加相应头
http{
server {
add_header 'Access-Control-Allow-Origin' *;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS';
location ~* ^/(fe-efficiency|monitor-visual|automated-testing-front)/ {
index index.html index.htm;
if (!-e $request_filename) {
rewrite ^/(fe-efficiency|monitor-visual|automated-testing-front)/(.*) /$1/index.html last;
break;
}
}
}
}