When doing Nginx load, we often encounter this situation:
2018/12/04 11:05:08 [crit] 2717#2717: *10 connect() to 127.0.0.1:5601 failed (13: Permission denied) while connecting to upstream, client: 172.16.4.33, server: 172.16.4.141, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5601/", host: "172.16.4.141"
A 502 error is displayed when the client accesses, and the firewall and load balancing configuration are all normal. It is normal for this machine to access 127.0.0.1:5601, and remote access is also normal, even if Nginx does forwarding, it will not work.
It is because of the limitations of SeLinux.
Turn off SeLinux
1. Temporary shutdown (no need to restart the machine):
setenforce 0: Set SELinux into permissive mode
setenforce 1: Set SELinux into enforcing mode (the default mode)
2. Modify the configuration file, need to restart the machine:
/etc/selinux/config file, change
just restart the machine.