问题描述:
下载文件的时候,点击下载会直接在浏览器中打开
解决过程:
首先在网上查了相关解决办法,尝试了在location中加入add_header,结果没有生效
location / {
add_header Content-Disposition "attachment;";
}
然后尝试了放入server中,可以生效,但是线上的服务器是没有开放具体端口的,所以应该尝试使这个配置在location中生效
最终办法:
尝试更改location后的路径,怀疑之前的正则表达式是不好用的,然后复制了下载链接:http://xxxxx.cn:8088//lb_tb/dict//10000428/%E5%8C%BB%E5%AD%A6%E9%A2%86%E5%9F%9F/2019-01-30-15_59_45/55a7be6f7df818bdc603fc9fc69275fa.txt
最后将location后的路径改为:
location /lb_tb/dict/ {
add_header Content-Disposition "attachment;";
}
至此,解决问题!