Nginx配置 txt、word、Excel、PDF文件在线下载并且跨域
server {
listen 32226;
client_max_body_size 1G;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_comp_level 1;
gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/javascript application/x-httpd-php image/jpegimage/gif image/png;
gzip_vary off;
gzip_disable "MSIE [1-6]\.";
location / {
root /app/files/static;
autoindex on;
add_header Content-Disposition: 'attachment;';
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
}