server绑定的默认80端口
location配置
location ~ ^/file {
if ($request_filename ~* ^.*?\.(txt|doc|pdf)$){
add_header Content-Disposition: 'attachment';
add_header Content-Type application/octet-stream;
}
root /home/wangjinyu;
测试文件下载链接:http://66.42.36.181/file/test.txt
就会下载/home/wangjinyu/file路径里的test.txt文件