Common Nginx 502 Bad Gateway solutions are as follows:
Nginx 502 Error Condition 1:
The number of visits to the Web site is large, while the php-cgi process is low.
For the 502 error in this case, simply increase the number of php-cgi processes. The specific is to modify the/usr/local/php/etc/php-fpm.conf file, the Max_children value of the appropriate increase. This data should be set according to your VPS or stand-alone server configuration. Generally a php-cgi process accounts for 20M of memory, you can calculate it by yourself, increase in amount.
/USR/LOCAL/PHP/SBIN/PHP-FPM restart and then reboot.
Nginx 502 Error condition 2:
CPU occupancy rate, memory footprint is very high, the CC attack.
Solution please refer to: Linuxvps simple solution cc attack
Nginx 502 Error Condition 3:
CPU usage is low and memory overflows.
Check the website program is there any problem? The General thief site will often appear memory overflow.
Check the log in the/var/log/directory to see if someone exploded the SSH and FTP ports?
SSH, FTP is exhaustive also can occupy a lot of memory. Yes, get rid of the SSH port and the FTP port.
To find some of the Internet and 502 bad gateway errors related to the problems and troubleshooting methods, first from the fastcgi configuration start:
1. See if the fastcgi process has started
The meaning of the NGINX 502 error is sock, the port is not being monitored. Let's check to see if fastcgi is running.
2. Check system fastcgi Process operation
In addition to the first case, the fastcgi process is not sufficient, PHP execution time is long, or the php-cgi process is dead can also cause Nginx 502 error
Run the following command to determine if the fastcgi process is approaching, and if the number of fastcgi processes is close to the value set in the configuration file, the number of worker processes is set too low
Netstat-anpo | grep "php-cgi" | Wc-l
3.FastCGI execution time is too long
Increase the following parameter values according to the actual situation
Fastcgi_connect_timeout 300; Fastcgi_send_timeout 300; Fastcgi_read_timeout 300;
4. The head is too big
Nginx, like Apache, has a front-end buffering limit that allows you to adjust the buffering parameters
Fastcgi_buffer_size 32k; Fastcgi_buffers 8 32k;
If you are using a Nginx load balancing proxying, adjust
Proxy_buffer_size 16k; Proxy_buffers 4 16k;
5.https Forwarding Configuration Error
The correct configuration method
Server_Name www.111cn.net Location/myproj/repos {set $fixed _destination $http _destination; if ($http _destination ~ * ^HTTPS (. *) $) {set $fixed _destination http$1;} proxy_set_header Host $host; Proxy_set_header X-real-ip $remote _addr; Proxy_set_header destination $fixed _destination; Proxy_pass http://subversion_hosts; }