我正在使用端口8080上的端口8081和Nginx监听应用程序 . 代理传递语句如下所示:
/var/etc/opt/lj/output/services/abc.servicemanager.conf
location /api/abc.servicemanager/1.0 { proxy_pass http://localhost:8081;}
在nginx.conf中,我将此文件包含为:
include /etc/nginx/conf.d/services/*.conf;
/etc/nginx/conf.d/service是一个符号链接:
# ll /etc/nginx/conf.d/
lrwxrwxrwx. 1 root root 39 Dec 10 00:19 services -> ../../../var/etc/opt/lj/output/services
这是Centos 7.0 SELinux Enabled系统 . 如果我setenforce 0,并使其Permissive,我没有看到任何问题 . 所以文件在正确的位置,路径没有问题 . 如果SELinux正在执行,我在审计日志中看到以下内容:
type=AVC msg=audit(1418348761.372:100930): avc: denied { getattr } for pid=3936 comm="nginx" path="/var/etc/opt/lj/output/services/abc.servicemanager.conf" dev="xvda1" ino=11063393 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:var_t:s0 tclass=file
我想知道如何启用Nginx来查找conf文件而无需禁用SELinux . 感谢您的帮助 .
-Vijay
4 回答
值得注意的是SELinux中的初学者,如果您的代理服务在8080上运行,您可以使用以下命令而无需编译策略 .
阅读audit2allow并使用它来创建一个策略,以允许访问nginx的被拒绝请求 .
始终更喜欢更改类型以创建自定义策略 . 在这种情况下,Nginx将提供
httpd_sys_content_t
类型的文件 . 假设您的文件位于/ var / www中:如果您有另一个端口或自定义端口允许它:
在http中显示允许端口:
这是在我的localhost输出:
并允许8081: