nginx为有效请求路径返回404

nginx为有效请求路径返回404,nginx,Nginx,我开始在我的服务器上部署letsencrypt,但很快就失败了,出现了一个非常令人沮丧的错误。我设置了一个webroot,并用一个示例hello.txt文件对其进行了测试: ~]# cat /tmp/letsencrypt-auto/well-known/acme-challenge/hello.txt hello ~]# ls -lZ /tmp/letsencrypt-auto/well-known/acme-challenge/hello.txt -rw-rw-r--. martin mar

我开始在我的服务器上部署letsencrypt,但很快就失败了,出现了一个非常令人沮丧的错误。我设置了一个webroot,并用一个示例
hello.txt
文件对其进行了测试:

~]# cat /tmp/letsencrypt-auto/well-known/acme-challenge/hello.txt
hello
~]# ls -lZ /tmp/letsencrypt-auto/well-known/acme-challenge/hello.txt
-rw-rw-r--. martin martin unconfined_u:object_r:user_tmp_t:s0 /tmp/letsencrypt-auto/well-known/acme-challenge/hello.txt
~]# cat /etc/nginx/conf.d/site.conf
<truncated>
    location /well-known/acme-challenge {
        default_type  "text/plain";
        root          /tmp/letsencrypt-auto;
    }
<truncated>

site.conf
文件当然包含其他指令,但即使我将它们全部注释掉,只留下
/well…
规则,它仍然返回404。你知道这是什么原因吗?文件显然存在,但感觉nginx看不到它。顺便说一句,关闭SELinux也没有什么帮助。

结果是,从
/tmp/
提供服务有些奇怪。当我把它移到我网站的
/srv/
位置时,一切都很好。

你能
cat
运行
nginx
的用户身份吗?@RichardSmith是的,我能。我使用
su-s/bin/bash-nginx
登录,可以很好地看到文件的内容。
2015/12/14 10:39:42 [error] 5898#5898: *232 open() "/tmp/letsencrypt-auto/well-known/acme-challenge/hello.txt" failed (2: No such file or directory), client: XXX, server: XXX, request: "GET /well-known/acme-challenge/hello.txt HTTP/1.1", host: "XXX"