Environment
- centos 7.6
- nginx version: nginx/1.20.1
- Nginx proxy 8989 traffic to IP: 8081
Phenomenon
After completing the Nginx reverse proxy configuration, /var/log/nginx/error.log reports an error
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”
Deal with
- Try to close Selinux, it runs normally
setenforce 0
systemctl restart nginx.service
- Generate PP file to join Selinux
cd /var/log/nginx
cat /var/log/audit/audit.log | grep nginx | grep denied | audit2allow -M mynginx
semodule -i mynginx.pp