[Solved] Nginx reverse proxy 502 permission denied

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

  1. Try to close Selinux, it runs normally
setenforce 0
systemctl restart nginx.service
  1. 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

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *