Nginx Server configuration PDF file download

Source: Internet
Author: User
Tags nginx server

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.