Posted On March 31, 2019

Error: 502 Gateway Error

kimconnect 0 comments
blog.KimConnect.com >> Codes , Linux >> Error: 502 Gateway Error
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/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

Leave a Reply

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

Related Post

PowerShell: Query Google Account Using GAM

$emailAddress='[email protected]' $field='accounts:last_login_time' function getGamUser{ param( $emailAddress, $field ) $result=try{gam report users user $emailAddress}catch{} if($result){ $headers=$result[0]…

PowerShell: Microsoft SQL Database Migration

Update 9/25/20: There's another version of this script has has been rewritten form scratch. IMO,…

Linux: How to Use Tar and Gunzip

Tar is an archival system. It helps bundling many directories and files into a single…