簡體   English   中英

如何配置 nginx 以提供 pdf 文件?

[英]How to cofigure nginx to serve a pdf file?

我正在嘗試通過在 nginx 中進行配置來提供 pdf 文件,但我在頁面中收到以下錯誤:404 Not Found

配置是這樣的:

server {

    listen 3002;
    index index.html;
    server_name _;

    location / {

        root /var/www/html/pdf_carpet;
        try_files $uri /index.html = 404;
    }
}

pdf_carpet 是 pdf 文件所在的位置。

為了能夠在 nginx 中提供 pdf 文件,我可以做些什么或改變什么?

PS 它適用於 html 文件。

Here is the full location block that should show the PDF file in the browser window under the http://<your_domain_or_IP>:3002/pdf_carpet URL:

location = /pdf_carpet {
    alias /var/www/html/pdf_carpet/file.pdf;
    default_type application/pdf;
    add_header Content-Disposition 'inline';
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM