We've been fighting to find the solution to random and frequent 502 Bad Gateway errors on many of our websites on one of our servers. They would generate entries like this in the site's proxy_error_log:
2016/06/17 08:55:46 [error] 23668#0: *24939 upstream prematurely closed connection while reading response header from upstream, client: x.x.x.x, server: domain.tld, request: "GET /script.php.
This occurred on sites with or without Nginx enabled in the Plesk control panel, and with FPM served by Apache, FastCGI served by Apache, but not FPM served by NGINX. This ultimately led us to "upstream" meaning Apache (i.e., an Apache issue).
What fixed it COMPLETELY was us switching Apache's MPM mode from "Event" to "Prefork" (which can be done in the Plesk control panel).
In our research we found TONS of folks with unresolved 502 errors. I thought I'd post this solution if it helps anyone else.
If someone has comments about WHY this worked, please let me know. We run Apache/2.4.6 on CentOS 7.2.1511. This machine in question has dual Xeon 8-core processors with 128 GB of memory.
Cheers!
- Paul
2016/06/17 08:55:46 [error] 23668#0: *24939 upstream prematurely closed connection while reading response header from upstream, client: x.x.x.x, server: domain.tld, request: "GET /script.php.
This occurred on sites with or without Nginx enabled in the Plesk control panel, and with FPM served by Apache, FastCGI served by Apache, but not FPM served by NGINX. This ultimately led us to "upstream" meaning Apache (i.e., an Apache issue).
What fixed it COMPLETELY was us switching Apache's MPM mode from "Event" to "Prefork" (which can be done in the Plesk control panel).
In our research we found TONS of folks with unresolved 502 errors. I thought I'd post this solution if it helps anyone else.
If someone has comments about WHY this worked, please let me know. We run Apache/2.4.6 on CentOS 7.2.1511. This machine in question has dual Xeon 8-core processors with 128 GB of memory.
Cheers!
- Paul