By default, the Nginx Server to access PDF file that is on the browser will directly open the PDF the file renders the content. If you want to access the pdf file, to achieve the effect of downloading the file, you need to do some configuration on the nginx server.
# VI nginx.conf Location/{if ($request _filename ~*^.*?\. ( TXT|DOC|PDF|RAR|GZ|ZIP|DOCX|EXE|XLSX|PPT|PPTX) {Add_header content-disposition: ' Attachment; ';}}
The above configuration is a matching file suffix, when the file suffix matches Pdf,rar When the file is accessed, the downloaded action is performed.
However, the above configuration is Chrome is not in effect, because Chrome will automatically identify the suffix of the file in the browser, when PDF file, the file is opened to recognize the content in the Web page.
need to modify PDF of the Mime-type .
# vi mime.types application/pdf octet-stream;
put Mime-type modified to Octet-stream after the Chrome can be downloaded as well.
This article from the "Play God Clown" blog, reproduced please contact the author!
Nginx Server configuration PDF file download