AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 801716
Accepted
LuMa
LuMa
Asked: 2016-09-08 15:44:46 +0800 CST2016-09-08 15:44:46 +0800 CST 2016-09-08 15:44:46 +0800 CST

SELinux阻止Nginx读取文件[重复]

  • 772
这个问题在这里已经有了答案:
两个相同的文件;Apache 说禁止使用 1 个回答
5年前关闭。

我在我的 CentOS 7 机器上运行 nginx。每天我都会运行一个生成新 Diffie-Hellman 参数的 cron 作业。它们保存在/etc/ssl/dh/dhparam.pem. 但是 SELinux 阻止 nginx 读取这个文件。

这是 nginx 错误日志中的行:

nginx[3189]: nginx: [emerg] BIO_new_file("/etc/ssl/dh/dhparam.pem") failed (SSL: error:0200100D:system library:fopen:Permission denied:fopen('/etc/ssl/dh/dhparam.pem','r') error:2006D002:BIO routines:BIO_new_file:system lib)

这是审核日志:

type=AVC msg=audit(1473285202.181:334): avc:  denied  { open } for  pid=1393 comm="nginx" path="/etc/ssl/dh/dhparam.pem" dev="dm-1" ino=101646309 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_tmp_t:s0 tclass=file
type=AVC msg=audit(1473285832.647:743): avc:  denied  { open } for  pid=2958 comm="nginx" path="/etc/ssl/dh/dhparam.pem" dev="dm-1" ino=101646309 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_tmp_t:s0 tclass=file
type=AVC msg=audit(1473287010.821:803): avc:  denied  { open } for  pid=3083 comm="nginx" path="/etc/ssl/dh/dhparam.pem" dev="dm-1" ino=101646316 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_tmp_t:s0 tclass=file
type=AVC msg=audit(1473287142.871:826): avc:  denied  { open } for  pid=3118 comm="nginx" path="/etc/ssl/dh/dhparam.pem" dev="dm-1" ino=101646309 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_tmp_t:s0 tclass=file
type=AVC msg=audit(1473287172.480:843): avc:  denied  { open } for  pid=3134 comm="nginx" path="/etc/ssl/dh/dhparam.pem" dev="dm-1" ino=101646309 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_tmp_t:s0 tclass=file
type=AVC msg=audit(1473287681.994:866): avc:  denied  { open } for  pid=3189 comm="nginx" path="/etc/ssl/dh/dhparam.pem" dev="dm-1" ino=101646309 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_tmp_t:s0 tclass=file

我对 SELinux 不是很熟悉(我知道我应该了解这一点):如何在不禁用 SELinux(或将其设置为允许)的情况下授予 nginx 访问权限?

centos nginx selinux
  • 1 1 个回答
  • 4875 Views

1 个回答

  • Voted
  1. Best Answer
    Michael Hampton
    2016-09-08T18:34:23+08:002016-09-08T18:34:23+08:00

    SELinux 拒绝您访问该文件,因为您将其从文件系统上的其他位置移动而不是复制到其最终位置。因此它保留了它的原始安全上下文,不允许 Apache 访问它。

    要解决此问题,请使用 重新标记文件restorecon。

    为避免以后出现问题,请复制文件(必要时删除原始文件),或使用mv -Z.

    • 10

相关问题

  • 如何在 Linux 机器上找到有关硬件的详细信息?

  • 使用 crontab 和 /etc/cron.hourly,daily,weekly 的区别

  • 持续监控许多服务器运行状况的简单方法?

  • Hudson 无法在 tomcat5 中启动

  • CentOS 的依赖挑战

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve