• 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

Issue Error 502 Bad Gateway - nginx

regisg

Regular Pleskian
Hello,
After the migration to a new, more powerful, VPS server (only changes: switching from CentOS 6.5 to Debian 8 Jessie + switching from Plesk 12.5 to Plesk Onyx), and without any change at the application level, we now encounter very often the following error on some PHP pages: "502 Bad Gateway - nginx", cf. Http://screenpresso.com/=ktaDe

However, the configuration seems completely identical between the two servers, including:
- Php: 5.6.28 as FastCGI application served by Apache (same problem when choosing FPM application served by Apache)
- opcache.enable: on

We thought this could come from the following parameter:
"Apache & nginx Settings:
Proxy mode (Nginx proxies requests to Apache)"
But if we uncheck this box it's even worse : we have "403 Forbidden" errors everywhere...

Please could you help us...?

Thanks a lot.
 
Hi regisg,

when you experience such "502 Bad Gateway" - issues with nginx, you probably use ".htaccess" - files at your domain. If you use ".htaccess" - files, pls. be aware that you might need "Additional NGINX directives", because NGINX can't read ".htaccess" - files. Pls. inform us with the content from possible ".htaccess" - files. Pls. note, that some wordpress - plugins for example might need "Additional APACHE + NGINX rewrites", when you use apache+nginx on your domain. The plugin - provider will normally provide such informations and you have to add these directives to your webserver - configuration. Consider to name additional plugins, so that people willing to help, have something to start with for their investigations.
 
Please see your fail2ban configuration if your public local IP has been blocked by it. If it is blocked, it is blocked for Apache. That prevents Apache from delivering content to Nginx, resulting in the "Bad Gateway" error, because Nginx senses that it does not receive content from the gateway. Add 127.0.0.1 and your public local IPv4 to the whitelist to solve this issue.

Besides this, there can be a hundred other issues. Normally, in your Nginx error log, more details can be seen what is causing the 502.
 
Back
Top