如何configurationSELinux的nginx来访问挂载目录的符号链接

我有一个运行nginx的libvirt vm,在nginx虚拟机上安装了一个共享文件系统,我想在这个安装目录中公开一个目录。 nginx似乎运行良好,我可以访问/ usr / share / nginx / html中的基本本地文件和子目录。 我有一个从挂载到默认nginx位置的符号链接,通过

ln -sf /mnt/h_drive/ss4/ /usr/share/nginx/html/ 

..我可以看到从浏览器的ss4目录,但是当我点击它,我得到的“403禁止”,并在我的/var/log/nginx/error.log

 2017/10/18 17:52:16 [error] 30806#0: *1 opendir() "/usr/share/nginx/html/ss4" failed (13: Permission denied), client: xxx.xxx.xxx.xxx, server: _, request: "GET /opt/ss4/ HTTP/1.1", host: "example.com" 

如果我禁用与setenforce 0 selinux我可以访问的一切。

我需要做什么才能访问这个挂载?

故障排除提示

以root身份安装

$ yum安装setroubleshoot-server -y

$ aureport -a#给出了有关拒绝的报告

$ ausearch -m avc -ts recent #last 10分钟

你应该能够更新政策

$ sudo audit2allow -a

上述报告运行时,您会发现类似的情况。

nginx system_u:system_r:httpd_t:s0 5个文件getattr unconfined_u:object_r:puppet_etc_t:s0 denied 616

创build策略

$ audit2allow -a -M读取

制定新政策

$ semodule -i read.pp

我最终偶然发现了一个解决scheme:

 semanage allow httpd_t nfs_t:dir read; 

感谢@bell的故障排除提示,我一定会参考他们的未来问题!