[英]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.