location /file {
charset utf-8;
alias /usr/share/nginx/html/files;
autoindex off;
autoindex_exact_size off;
autoindex_localtime on;
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'Origin, X-Requested-With, Content-Type, Accept' always;
location ~* \.(jpg|png)$ {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' ', X-Requested-With, Content-Type, Accept' always;
}
}
标签:Control,预览,header,always,Access,nginx,add,Allow,文件类型
From: https://www.cnblogs.com/qcy-blog/p/17817297.html