FIX ERROR – CentOS+Nginx+Jenkins: 502 Bad Gateway

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: 1.2.3.4, server: jenkins.artem.services, request: “GET / HTTP/1.1”, upstream: “http://127.0.0.1:8080/”, host: “jenkins.artem.services”

 

Solution:

Reason SELinux. You can either allow Jenkins or disable SELinux.

Option to disable SELinux

Open the configuration file:

vim /etc/selinux/config

 

And change “enforcing” to “disabled

SELINUX=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

Tagged: Tags

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments