【发布时间】:2019-07-04 15:25:13
【问题描述】:
我在example.com 和www.example.com 有一个Ghost 站点(在内部,它在端口2368 上运行)。同时,我有一个名为form.pdf 的文件,我想让它在以下位置可用(在浏览器中查看,而不是要求用户下载):
example.com/form.pdfwww.example.com/form.pdf
使用下面的配置,它只有在 .pdf 扩展名之后包含斜杠时才有效,如下所示:
example.com/form.pdf/www.example.com/form.pdf/
PDF文件路径:
/var/www/ghost/pdfs/form.pdf
配置文件路径:
/etc/nginx/sites-available/ghost
配置文件:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name 123.45.678.901 localhost example.com *.example.com;
root /usr/share/nginx/html;
index index.html index.htm;
client_max_body_size 100M;
location "/form.pdf" {
alias /var/www/ghost/pdfs;
index form.pdf;
}
location / {
proxy_pass http://localhost:2368;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
}
}
当我删除 .pdf 扩展名后的斜杠时,出现 404 错误。
问题:
如何正确配置 Nginx 使其在末尾没有斜杠的情况下工作?
【问题讨论】:
标签: nginx ghost-blog