server {
listen 443 ssl;
server_name localhost;
ssl_certificate key/1__.hexunzc.com_bundle.crt;
ssl_certificate_key key/2__.hexunzc.com.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html index.htm;
add_header Content-Disposition "attachment; filename=$1";
}
listen 443 ssl;
server_name localhost;
ssl_certificate key/1__.hexunzc.com_bundle.crt;
ssl_certificate_key key/2__.hexunzc.com.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html index.htm;
}
add_header Content-Disposition "attachment; filename=$1";
}
}
在nginx.conf文件中添加红色部分的配置,即当 /attach/product/financing/ 这个目录下的文件被请求时加上一个头部信息告诉浏览器直接下载文件而不是打开,比如pdf
本文介绍如何在Nginx中配置特定目录下文件的自动下载功能,通过添加指定的HTTP头部来改变浏览器的行为,使其将请求的文件作为附件直接下载。

9124

被折叠的 条评论
为什么被折叠?



