收到存在于 nginx Web 服务器中的文件的 404

JWF*_*JWF 5 image nginx centos http-status-code-404

我最近将 CentOS 7 机器上的 Web 服务器从 Apache 切换到 nginx。我使用软件在我的电脑上截取屏幕截图并将它们上传到服务器以供公众查看。最初,它在 Apache 上运行良好 - 但是,现在我遇到了一个问题,即 nginx 将为 Web 服务器上的某些 .png 图像提供 404 错误。

我用一个非常相似的问题提到了这个问题,但在我自己的问题的背景下,我无法理解解决方案。

我有下面图像服务器的服务器块的片段。

server {
    listen       80;
    server_name  imageserver.example.com;
    root         /usr/share/nginx/imageserver.example.com/public_html;

    access_log   imageserver.example.com/logs/imageserver.example.com_access.log;
    error_log    imageserver.example.com/logs/imageserver.example.com_error.log crit;

    location / {
        index  index.html index.htm;
    }

    location ~* \.png {
        root       imageserver.example.com/public_html/u/;
        expires    max;
        add_header Pragma public;
        add_header Cache-control "public, must revalidate, proxy-revalidate";
    }
}
Run Code Online (Sandbox Code Playgroud)

示例链接是此图像。我已确认该文件存在于服务器上,并且具有以下权限。

$ lsa 7b724394b851299c68b15f1172f158c6.png -rw-rw-r--. 1 jflory nginx 2.4K Nov 3 11:13 7b724394b851299c68b15f1172f158c6.png

我对如何解决这个问题感到非常困惑。可能是什么问题?

Ric*_*ith 6

root容器中的指令会location ~* \.png在 URL 末尾添加 /u/,因此服务器会在 /u/u/ 中查找图像。

root指令实际上是不必要的,因为该值将从块中定义的值继承server