【发布时间】:2017-07-10 05:02:39
【问题描述】:
我使用 nginx 作为代理(使用location /)并尝试为另一个位置块下的热链接保护重定向提供静态图像。以下是我用来尝试提供图像的内容。我已将 root 指令移到 location 块之外,这是 nginx 出于某种原因构建正确路径所必需的。
location = /hotlink.png {
autoindex off;
try_files hotlink.png hotlink.png
}
但是,当我查看日志时,它仍在通过将 URI 附加到根路径:{root}/hotlink.png/index.html 来查找 index.html。
我只是希望它仅在 /hotlink.png 匹配时发送文件 {root}/hotlink.png ,仅此而已。
为什么它还在寻找带有autoindex off 的索引?我该如何解决这个问题,或者有没有更好的方法来处理这种情况?
【问题讨论】:
-
删除
try_files声明。 -
@RichardSmith 这就是我最初拥有的。如果没有
try_files,它似乎完全跳过了该块并退回了location /块 -
hotlink.png是真实文件吗? -
是的,这是一个真实的文件
标签: http nginx nginx-location