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: Windows Systems Inventory

<# Systems-Inventory.ps1 Version: 0.04 Purpose: to generate a report with information about servers on the…

PowerShell: Set PasswordNeverExpires on SamAccountName

Quick 1-liner Code $accounts=@( 'orange', 'apple', 'pear', 'dog', 'cat', 'dinosaur', 'chicken', 'cow', 'yomama', 'yodada' )…

PowerShell: Convert CSV Into HashTable

This is an illustration of a function to convert a set of CSV contents into…