问题描述
RHEL8服务器安装有Apache做文件访问用,数据卷是/dev/sdb
挂载在/nfs
下,要从网站访问的内容存在于/nfs/perf-insight/
路径下,在Apache默认路径下设有同名软连接即/var/www/html/perf-insight/
。
访问网站提示“Forbidden”,查询错误日志/var/log/httpd/error_log
提示如下:
[Tue Jan 19 16:38:25.344744 2021] [autoindex:error] [pid 6095:tid 139653503821568] (13)Permission denied: [client 10.72.12.63:46114] AH01275: Can't open directory for index: /var/www/html/perf-insight/
检查文件权限无误,检查SELinux Context不匹配:
# ls -lZd /var/www/html/perf-insight
lrwxrwxrwx. 1 root root unconfined_u:object_r:httpd_sys_content_t:s0 18 Dec 29 14:48 /var/www/html/perf-insight -> /nfs/perf-insight/
# ls -lZd /nfs/perf-insight
drwxrwxrwx. 5 root root unconfined_u:object_r:unlabeled_t:s0 54 Jan 19 17:22 /nfs/perf-insight
临时关闭SELinux网站可以正常访问,故此确定问题所在。
# setenforce 0
......
# setenforce 1
深入研究
检查SELinux日志:
# tail -n 3 /var/log/audit/audit.log | tee /tmp/audit
type=AVC msg=audit(1611062693.562:138): avc: denied {
read } for pid=1179 comm=</