Explanation:
502 Gateway Error generally means connection problems with an upstream proxy. In this instance, Apache is the upstream to NGINX.
Troubleshooting steps:
1. Test Apache directly to see that it can host from such ports
curl -I http://127.0.0.1:8080/
#####
HTTP/1.1 200 OK
#####
2. Check NGINX error log
tail /var/log/nginx/error.log
#####
2019/02/01 23:20:18 [crit] 21974#21974: *7 connect() to 127.0.0.1:8080 failed (13: Permission denied) while connecting to upstream, client: xx.xx.xx.xx, server: kimconnect.com, request: “GET /info.php HTTP/1.1”, upstream: “http://127.0.0.1:8080/info.php”, host: “kimconnect.com”
#####
3. Check SELinux logs
cat /var/log/audit/audit.log | grep nginx | grep denied
#####
type=AVC msg=audit(1549092018.112:22234): avc: denied { name_connect } for pid=21974 comm=”nginx” dest=8080 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:http_cache_port_t:s0 tclass=tcp_socket permissive=0
#####
Resolution:
# Configure SELinux to allow httpd to connect to nginx
setsebool -P httpd_can_network_connect 1
# Make rule permanent
setsebool httpd_can_network_connect on -P