【问题标题】:nginx won't load a conf file that is symlinkednginx 不会加载符号链接的 conf 文件
【发布时间】:2016-01-11 22:59:37
【问题描述】:

我有 2 台服务器(新的和旧的)

在两台服务器上都有一个名为 mysite.conf 的 conf 文件,它符号链接到 /var/local/mysite/conf/mysite.conf

/etc/nginx/conf.d/mysite.conf -> /var/local/mysite/conf/mysite.conf

在旧服务器上,一切正常。但是,在新服务器上,它不会遵循符号链接。如果我将 conf 文件设为真实文件,那么 nginx 将加载它 /etc/nginx/conf.d/mysite.conf 并且它可以工作。

可能有什么不同?

.conf 文件的文件权限相同。

主要的 /etc/nginx/nginx.conf 文件是相同的。

【问题讨论】:

  • 检查所有父目录的权限
  • 两台机器上的文件/目录权限相同。 conf 文件为 644,目录为 755。
  • 这可能与 SELinux 有关。有一些与此相关的问题
  • 我也这么认为。我可以在 /var/log/audit/audit.log 中看到一些内容。我使用了 audit2why 和 audit2allow,创建了一个模块,安装了它,但是没有用。另一台服务器工作,但这个没有。那里有一个线索。

标签: nginx


【解决方案1】:

尝试添加到您的 nginx.conf 文件中:

http {
    disable_symlinks off;
}

【讨论】:

  • 我相信该设置不是为了跟踪 conf 文件上的符号链接,而是为了跟踪正在提供的文件上的符号链接。不过,我试过了,还是不行。
【解决方案2】:

我想通了。它是 SELinux。谢谢阿列克谢十。要治愈它,您需要制作一个模块来调整 SELinux 设置。

tail /var/log/audit/audit.log | audit2why
tail /var/log/audit/audit.log | audit2allow -m myapplocal > myapplocal.te
tail /var/log/audit/audit.log | audit2allow -M myapplocal 
semodule -i myapplocal.pp 

对我来说,生成的模块如下所示:

require {
    type httpd_t;
    type var_t;
    class file getattr;
}

#============= httpd_t ==============
allow httpd_t var_t:file getattr;

【讨论】:

    猜你喜欢
    • 2015-05-05
    • 2012-09-19
    • 2018-09-02
    • 1970-01-01
    • 2020-08-04
    • 1970-01-01
    • 2013-08-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多