About 502 of Nginx's loading and playing the strange Road

Source: Internet
Author: User
Tags php error php error log

Write the log before you copy a section of nginx502 reasons, from a network to see the following, however, this is not the focus, the most important thing is to see Bo Master hand knock.

First, NGINX 502 error Troubleshooting
NGINX 502 Bad Gateway error is a fastcgi problem, causing NGINX502 errors more likely. List some of the online and 502 Badgateway errors related problems and troubleshooting methods, start with the fastcgi configuration:
whether the 1.FastCGI process has started
2.FastCGI worker process number is not enough
Run Netstat-anpo | grep "php-cgi" | Wc-l determine if close to the fastcgi process, close to the value set in the configuration file, indicating that the number of worker processes is set too low
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.FastCGI Buffer Not enough
NginxLike Apache, there are front-end buffering restrictions that can be adjusted for buffering parameters
Fastcgi_buffer_size 32k;
Fastcgi_buffers 8 32k;
5.Proxy Buffer Not enough
If you use a proxying, adjust
Proxy_buffer_size 16k;
Proxy_buffers 4 16k;
See also: http://www.server110.com
6.https Forwarding Configuration error
The correct configuration method
server_name www.mydomain.com;
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;
}
Of course, it depends on what type of fastcgi you use, I have used php-fpm, the flow is about a single machine 400,000 PV (Dynamic page), and now basically did not touch 502.

7.php script execution time is too long
Change the 0s of php-fpm.conf's <valuename= "Request_terminate_timeout" >0s</value> to a time

~~~~~~~~~~~~~~~~~~~~~~~~~~~ Gorgeous split-line ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Bloggers encounter the problem is because the code has a parameter passed by reference, and then access directly after 502, bloggers see this information, the first time is to directly open the display_errors,

And then I had a question. Why open the error display, not 502, just some e_strict warning, after a round of debugging, still no way after the reason.

Helpless after viewing the nginx error is as follows. At that time think this Nima is not PHP fastcgi error, why will appear in Nginx bug log inside, this feeling is not scientific, thinking

After a few rounds of pain and no effect of the commissioning, still feel powerless, can only be temporarily adjourned.

As a lucky programmer, I don't know how to move that Daoteng. After a while, the local virtual machine environment has not written the error log file, the configuration is no problem, is not to write the error log. (Everyone crossing do not spit groove, because bloggers are usually direct page display error plus xdebug, so feel indifferent, do not write off my drizzle of things, not empty. Bo Master Eye heightening and other wisdom of the brain (this time to write bloggers must add some force lattice) think it should be the file permissions, and then decisive to chmod 777 superb skills, restart PHP-FPM, to the section error code test, or as expected to write the error log file. At the moment in retrospect the problem of the morning, always feel the output of the error warning God horse will not and write the same log. Think that naked clothes dry, tail the error log, screen display, and the code, and now do not report 502, perfect operation, error log writing log file As expected, unscientific ah, open nginx error log again to find Nginx no error. All right! Feel the problem found about the 502 error is due to PHP error log permissions problem, there is no way to write, and then directly to the CGI, so Nginx is 502. As for why the next throw to CGI, this I do not understand, do not ask me, understand the people behind a few strokes. Ah yo, good oh. This is the end of the journey. Thank you TVB, thank you mom and dad, thank you blog Park.

About 502 of Nginx's loading and playing the strange Road

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.