实现目的:打开浏览器自动下载文件
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
if ($request_filename ~* ^.*?\.(txt|doc|pdf|rar|gz|zip|docx|exe|xlsx|ppt|pptx)$){
add_header Content-Disposition "attachment;";
}
}
}