gpt4 book ai didi

nginx - 启用 SELinux 后 proxy_pass 不起作用,为什么?

转载 作者:行者123 更新时间:2023-12-03 14:27:31 24 4
gpt4 key购买 nike

我有一个应用程序在端口 8081 上监听,Nginx 在端口 8080 上运行。代理传递语句如下所示:

$ cat /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是一个符号链接(symbolic link):
# 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 ,并使其变得宽容,我没有看到任何问题。所以文件在正确的位置,路径没有问题。如果 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。

最佳答案

对于 SELinux 的初学者,值得注意的是,如果您的代理服务在 8080 上运行,您可以使用以下命令而无需编译策略。

$ sudo setsebool httpd_can_network_connect 1 -P

关于nginx - 启用 SELinux 后 proxy_pass 不起作用,为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27435655/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com