nginx cache dir creation-strange behavior

时间:2018-06-18 15:43:30

标签: nginx centos7 file-permissions selinux

我的nginx.conf中有以下行(加上下文):

http {
    proxy_cache_path cache/  keys_zone=auth_cache:10m;
    ...

由于nginx.conf位于/etc/nginxcache/对应/etc/nginx/cache。     drwxr-XR-X。 5 root root 205 Jun 18 16:25 / etx / nginx

(我也用绝对路径/apps/nginx/cache/

尝试了这个
drwx------. 2 nginx nginx 6 Jun 18 14:42 /apps/nginx

在任何一种情况下,当我尝试

$ sudo systemctl start nginx

失败了。 journalctl -u nginx告诉我以下内容:

... nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
... nginx: [emerg] mkdir() "/etc/nginx/cache" failed (13: Permission denied)
... nginx: configuration file /etc/nginx/nginx.conf test failed

(在备用方案中,确实会说"/apps/nginx/cache"。)

然后我试着

$ sudo systemctl start nginx-debug

并且启动没有任何问题,错误或警告日志。它会在cache/中指定的任何位置创建nginx.conf目录,当我停止并启动nginx服务时,这也会正常启动。

我需要了解导致这种情况的原因,因此我可以编写自动化和配置管理,以便开箱即用。 我的两个假设是:

  1. 这是SELinux问题,而服务/二进制文件nginx-debugnginx有不同的标记/限制。
  2. 启动nginx时的飞行前检查尝试将目录创建为其他目录。非特权用户,但nginx-debug会跳过这些检查,从而以root或nginx创建目录。
  3. 知道如何有效地深入了解这一点吗? 谢谢!

0 个答案:

没有答案
相关问题