When running Nginx as a reverse proxy to Jenkins on CentOS, a 502 error may occur. Nginx error log will be as follows:
2020/05/07 13:32:33 [crit] 9665#9665: *1 connect() to 127.0.0.1:8080 failed (13: Permission denied) while connecting to upstream, client: 126.96.36.199, server: jenkins.artem.services, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "jenkins.artem.services"
Reason SELinux. You can either allow Jenkins or disable SELinux.
Option to disable SELinux
Open the configuration file:
And change "enforcing" to "disabled"
And restart the server.
In CentOS 6, you can disable SELinux without rebooting (CentOS 7/8 - require a reboot) by running the following command:
echo 0 > /selinux/enforce