In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article shows you the causes and solutions of Nginx 502 Bad Gateway errors. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Recently, many companies have encountered 502 error pages on their websites, which are summarized by themselves.
Then look for the following answers on the Internet, summarize some reasons and solutions, in case of 502 in the production environment
There are many situations where 502 errors will occur. Let's talk about them on a case-by-case basis.
1. The fastcgi buffer setting is too small
If there is an error, first look for the log file of nginx, the directory is / var/log/nginx, and the following error is found in the log.
13:33:47 on 2013-01-17 [error] 1542120: * 16 upstream sent too big header while reading response header from upstream
After consulting the data, it is to the effect that there is a bug in the nginx buffer, and the page consumption of our website may take up too much of the buffer.
I looked up the solution on the Internet, and saw a way to increase the buffer zone on foreign websites, which completely solved the problem of Nginx 502Bad Gateway. The methods are as follows:
Http {
... Fastcgi_buffers 8 16k; fastcgi_buffer_size 32k;
}
Please increase the above two configuration items according to the situation that the server already has a website.
Second, the proxy buffer setting is too small
If you use a nginx reverse proxy, if the header is too large and exceeds the default 1k, the above upstream sent too big header will be triggered (to put it bluntly, the nginx sends the external request to the backend for processing, and the header returned by the backend is too large for the nginx to handle.
Server {
Listen 80; server_name * .lxy.me; location / {
Add these three lines
Proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for
.
}
3. The number of processes set by default PHP-cgi is too small.
There are 502 problems in the process of installation and use, generally because the default php-cgi process is 5, which may be caused by insufficient phpcgi processes, so you need to modify / usr/local/php/etc/php-fpm.conf to increase the max_ child value appropriately. It is also possible that the max_requests value is not enough. It should be noted that this configuration item takes up a lot of memory, so please set it according to the server configuration. Otherwise, it may be counterproductive.
4. Php execution timeout
Php execution timed out, modify / usr/local/php/etc/php.ini to change max_execution_time to 300
5. Nginx waiting time timed out
The execution time of some PHP programs exceeds the waiting time of Nginx, so the timeout time of FastCGI in nginx.conf configuration file can be increased appropriately.
Http {
Fastcgi_connect_timeout 300
Fastcgi_send_timeout 300
Fastcgi_read_timeout 300
……
}
The above is the cause of the Nginx 502 Bad Gateway error and what is the solution. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.