允许SELinux、Nginx读取本地文件并建立出站连接

允许SELinux、Nginx读取本地文件并建立出站连接

我是使用 CentOS 7、nginix 和 php-fpm 的服务器的新管理员。有一个 Web 表单需要读取本地文件 (prod.pem),然后与以下任一文件建立出站连接:

gateway.push.apple.com:2195
gateway.sandbox.push.apple.com:2195

在 audit.log 中,我看到以下 2 个条目:

type=AVC msg=audit(1465918007.693:406): avc:  denied  { read } for  pid=1796 comm="php-fpm" name="prod.pem" dev="dm-0" ino=19554
type=SYSCALL msg=audit(1465918007.693:406): arch=c000003e syscall=2 success=no exit=-13 a0=7fff2ee13570 a1=0 a2=1b6 a3=24 items=0 ppid=1213 pid=1796 auid=4294967295 uid=997 gid=996 euid=997 suid=997 fsuid=997 egid=996 sgid=996 fsgid=996 tty=(none) ses=4294967295 comm="php-fpm" exe="/usr/sbin/php-fpm" subj=system_u:system_r:httpd_t:s0 key=(null)

我的/etc/selinux/config

SELINUX=enforcing
SELINUXTYPE=targeted

如何配置 SELinux 以允许读取文件并建立出站连接?我还想确保这些在重启后仍能保留。

答案1

这对我来说是这样的:

setsebool -P httpd_read_user_content 1
setsebool -P httpd_can_network_connect 1

-P使其在重启后依然有效。

相关内容