环境
- centos 7.6
- nginx version: nginx/1.20.1
- nginx 代理 8989 流量到 IP:8081
现象
在完成Nginx反向代理配置后,/var/log/nginx/error.log报错
2021/08/20 16:23:52 [crit] 11490#11490: *5 connect() to IP:8081 failed (13: Permission denied) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "http://IP:8081/", host: "127.0.0.1:8989"
处理
- 尝试关闭Selinux,运行正常
setenforce 0
systemctl restart nginx.service
- 生成PP文件加入Selinux
cd /var/log/nginx
cat /var/log/audit/audit.log | grep nginx | grep denied | audit2allow -M mynginx
semodule -i mynginx.pp