Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the common Nginx 502 error problem in linux

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Xiaobian to share with you how to solve Nginx common 502 error problems in linux, I hope you have gained something after reading this article, let's discuss it together!

Nginx 502 Error 1:

The site gets a lot of traffic, and php-cgi gets a lot less traffic.

For 502 errors in this case, simply increase the number of php-cgi processes. Specifically, modify the/usr/local/php/etc/php-fpm.conf file to increase the max_children value appropriately. This data depends on the configuration of your VPS or standalone server. Generally a php-cgi process accounts for 20 MB of memory, you can calculate yourself, the right amount of increase.

The requested URL/usr/local/php/sbin/php-fpm was not found on this server.

Nginx 502 Error Case 2:

CPU usage, memory usage is very high, CC attack.

Please refer to LinuxVPS for a simple solution to CC attacks

Nginx 502 error case 3:

CPU usage is not high, memory overflow.

Check if there are any problems with the website program? General thief sites often occur memory overflow.

Check the logs in/var/log/directory to see if someone is blasting SSH and FTP ports.

SSH, FTP will also occupy a lot of memory by exhaustive. If yes, change SSH port and FTP port.

Here are some of the problems and troubleshooting methods found online related to the 502 Bad Gateway error, starting with FastCGI configuration:

1. Check to see if FastCGI process has started

NGINX 502 error means that the sock and port are not monitored. Let's check if fastcgi is running

2. Check system Fastcgi process health

In addition to the first case, there are not enough fastcgi processes, php execution time is long, or php-cgi process death may also cause nginx 502 error

Run the following command to determine if FastCGI processes are close. If the fastcgi process count is close to the value set in the configuration file, the worker process count is set too low

netstat -anpo | grep "php-cgi" | wc -l

FastCGI takes too long to execute

Adjust 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 front-end buffer limits and can adjust buffer parameters

fastcgi_buffer_size 32k; fastcgi_buffers 8 32k;

If you are using nginx Load Balancer Proxying, adjust

proxy_buffer_size 16k; proxy_buffers 4 16k;

5. https forwarding configuration error

The correct configuration method

server_name www.jb51.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; } After reading this article, I believe you have a certain understanding of "How to solve Nginx common 502 error problems in Linux". If you want to know more about this knowledge, please pay attention to the industry information channel. Thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report