• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Resolved Plesk 12.5: 502 bad gateway

Alban Staehli

Regular Pleskian
Hi,

As mentioned in another post (http://talk.plesk.com/threads/ppp-1...or-resolver-unfitsettingsresolver-php.334378/), since migration from another server to a clean CentOS 7 with Plesk 12.5, I encountered a "502 Bad Gateway" sent from Nginx for all vhosts.
I had to follow http://kb.odin.com/en/123735 in order to repair the web server configuration.

It worked well, except from time to time, I run again into the "502 Bad Gateway" for all vhosts.
Therefore, I disabled Nginx until a fix to this issue is found.
/usr/local/psa/admin/bin/nginxmng --disable

Do you have any idea of what is the root cause of this issue?

Thx for your great support.
 
Will try, but the problem is not related to Plesk Admin. It's related to all websites, suddenly, after a while once nginx re-activated. Prior to the migration, the old server running Plesk 11.5 didn't encounter such issue.
Did you identify this problem as a bug in 12.5? Or do you think it's just not related to the new Plesk version?
 
Did you identify this problem as a bug in 12.5? Or do you think it's just not related to the new Plesk version?
It's depends of many possible reasons and can't be identified as bug in 12.5. For example, lack of resources for VPS, specific nginx or PHP settings, etc.
 
It's depends of many possible reasons and can't be identified as bug in 12.5. For example, lack of resources for VPS, specific nginx or PHP settings, etc.
The funny thing is that I migrated actually from a VPS to a clean OpenVz container on a dedicated server. Plesk admin shows that only 1% of the RAM is used. I didn't tweak PHP setting or nginx on the new server, I just did a migration using the PSA tool.
 
There are a lot of different resources in VPS besides RAM. Just run

# cat /proc/user_beancounters

and check resources with non-zero failcounters, for example.
 
I had the same issue.
Migrated from 12.0 to 12.5 on Debian 7.0 worked fine. But then dist-upgrading from 7 to 8 (using procedure provided by plesk with pre- and post-installation scripts) trouble began.
Then I had to disable nginx because it was just very unreliable.
A day later I noticed that Apache was failing as well. Somehow, the limits in mpm_event were being reached. So I raised the limits and since then apache has been doing fine.
I am pretty sure (but not 100%) that I was not using mpm_event prior to this.
So it could be that nginx encountered problems because it basically overloaded apache with is default mpm_event settings?
I did not reenable nginx yet, will try so this weekend if I have time...
 
A day later I noticed that Apache was failing as well. Somehow, the limits in mpm_event were being reached. So I raised the limits and since then apache has been doing fine.
I am pretty sure (but not 100%) that I was not using mpm_event prior to this.

How did you raise mpm_event limits?
I'm sure I wasn't using mpm_event before.

On my side, I also discovered Apache was crashing from time to time, and I activated prefork to see if it goes better.
 
@Alban Staehli I edited this file:
Code:
/etc/apache2/mods-enabled/mpm_event.conf
<IfModule mpm_event_module>
        StartServers                     4
        MinSpareThreads          50
        MaxSpareThreads          150
        ThreadLimit                      64
        ThreadsPerChild          25
        MaxRequestWorkers         500
        MaxConnectionsPerChild   0
</IfModule>

But, very funny things, after just installing the 12.5.0 update #2, somehow mpm_prefork became active again.
 
There are a lot of different resources in VPS besides RAM. Just run

# cat /proc/user_beancounters

and check resources with non-zero failcounters, for example.

I just did the following test:
- apache in prefork mode
- /usr/local/psa/admin/bin/nginxmng --enable
- /usr/local/psa/admin/sbin/httpdmng --reconfigure-all
- accessed to different hosted websites => after 5min: 502 bad gateway from Nginx
- cat /proc/user_beancounters => failcount is at 0 everywhere

So I'll continue to disable nginx for now on...
Any clue where to look and what to do?

Thx for your help.
 
I just got an update for the sw-nginx package.
Code:
Unpacking sw-nginx (1.9.4-debian8.0.15091112) over (1.9.2-debian8.0.15080716) ...
[....] Starting new master nginx: nginx failed!
[info] NGINX upgrade failed. Attempting hard restart..
[....] Restarting nginx (via systemctl): nginx.serviceJob for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details.
 failed!
Ok, maybe it has to do with nginx being disabled in plesk. Would like to know what has changed in this package version though, before reenabling nginx again. I really don't want to mess up reliability.
 
Just updated my installation with the 3rd micro-update...
Ran the same test:
- apache in prefork mode
- /usr/local/psa/admin/bin/nginxmng --enable
- /usr/local/psa/admin/sbin/httpdmng --reconfigure-all
- accessed to different hosted websites => after 5min: 502 bad gateway from Nginx
- cat /proc/user_beancounters => failcount is at 0 everywhere

Problem is still there. And I can't see any errors in logs for the vhost, apache or nginx...
Only alerts: nginx => 2015/09/22 18:42:20 [alert] 16448#0: *543 open socket #182 left in connection 9

Where else to look?

@H9k Did you try to re-enable NGINX?
 
502 bad gateway from Nginx
Many different reasons may be there. I suggest you try to find solution in KB articles. There are may articles about "502 bad gateway". Just try to use KB search and read articles.
Contact Odin Support Team if it not help.
 
Hi,
I went further with this issue...

Analyse & Tests
Al right, I followed all of those articles:
http://kb.odin.com/en/124377
http://kb.odin.com/en/122103
http://kb.odin.com/en/113976
http://kb.odin.com/en/125357
None of them helped me, meaning that I couldn't see anything wrong with my setup following these articles. Apache was up & running (on the good port), no error messages in the logs, and so on....

And of course, I followed this one to enable/disable Nginx:
http://kb.odin.com/en/123735

Meanwhile I was doing my tests, I realized that Nginx was showing 502 Bad Gateway after Apache got restarted. In the error log, I've seen this message:
[Sun Sep 27 15:53:24.989720 2015] [mpm_prefork:notice] [pid 6818] AH00170: caught SIGWINCH, shutting down gracefully

Therefore, I was wondering why Apache restarts so often?
And I realised that each time I load the "Home Page" of Plesk Admin, I've this line in the error log!
So, it seems Plesk Admin 12.5 restarts Apache each time I go to its "Home Page". @IgorG : is this a normal behaviour?
How did I figure that out? I ran this command through ssh
tail -fn0 /var/log/httpd/error_log
And I logged into Plesk. Each time I load the "Welcome Page", I see the "SIGWINCH" line appearing...

Solution?
Anyway, following @H9k advice, I tried to tune my mpm_prefork parameters.
vi /etc/httpd/conf.d/mpm_prefork.conf

With 10go of RAM, I set it as follow:
<IfModule prefork.c>
StartServers 2
MinSpareServers 2
MaxSpareServers 5
ServerLimit 200
MaxRequestWorkers 200
MaxClients 200
MaxRequestsPerChild 0
</IfModule>
I also set the KeepAlive option to On.

A good article to define these limits according to your own setup can be found here:
http://cloudinservice.com/tune-apache-performance-using-mpm-prefork-module/

This made the server stable with NGINX for now on!
 
Hi @Alban Staehli , looking at the just released plesk 12.5.30 Update 4 logs, there is something about an issue with Apache restarting frequently.
Maybe that fixes the problem?
Anyway, I will try your configuration and reenabling nginx in the coming days/weeks.
 
I had the bad gateway error as well, but only when I clicked on "Websites and domains" and only during that time when the page was loading all other sites were getting bad gateway. This happened until I disabled ModSecurity with Basic Atomic rules.
 
I just saw update 4 of 12.5.30 release notes and they did talk about "server restarting" when the basic rules with kid security were used. This was released like 6 hours ago ? It seems ? Not sure why I only noticed it if it was released for a while. Testing now with ModSecurity on. But the page is still slow to load the "websites and domains" with mod security on, not sure why ... This is this ONLY page that is slow. Maybe some inefficient coding on that page ? Maybe a rule is triggering something on that page ( that's in power user view ). But so far it's not rebooting Apache it seems. Will see tomorrow.
 
Back
Top