location / {
if ($request_filename ~* ^.*?.(txt|doc|pdf|rar|gz|zip|docx|exe|xlsx|ppt|pptx)$)
{
add_header Content-Disposition 'attachment';
add_header Content-Type: 'APPLICATION/OCTET-STREAM';
}
autoindex on;
root html;
index index.html index.htm;
}
在location中添加如下内容
if ($request_filename ~* ^.*?.(txt|doc|pdf|rar|gz|zip|docx|exe|xlsx|ppt|pptx)$)
{
add_header Content-Disposition 'attachment';
add_header Content-Type: 'APPLICATION/OCTET-STREAM';
}