nginx配置文件下载,不预览 location配置 location ~ ^/file { # 括号中类型,指定浏览器不预览文件直接下载 if ($request_filename ~* ^.*?\.(txt|doc|pdf|png)$){ add_header Content-Disposition: 'attachment'; add_header Content-Type application/octet-stream; } root /file; #proxy_pass http://xx.xx.xx.xx/; }