An nginx 502 problem solution

environment:

A windows machine only runs nginx as a proxy.
A linux server, lnmp environment, running a php website.

question:

The proxy is done on nginx of windows, and the related parameters of the nginx.conf configuration file have not been adjusted. It ran normally on the first day, and 502 appeared on the second day. There was no problem with direct hosts to bind the ip access of the linux server.

I believe that most people will not suspect that the problem lies in the linux server. After all, there is no problem with binding hosts to access directly. Therefore, after tossing on windows for a long time, no matter restarting the nginx service or restarting the system, it is still 502.

查看windows上nginx的错误日志error.log,发现很多“[error] 2420#2560: *27 WSARecv() failed (10054: An existing connection was forcibly closed by the remote host) while reading response header from upstream ” 

This kind of log is rare, but it can be determined that the problem is on the linux server. So I went to the linux server to open the error log, but unfortunately did not find any problems. Go to google it, but can't find a good solution.

solve:

Fortunately, I have encountered a similar problem before, but it was linux proxying linux, and the symptoms were basically similar to this problem. The solution at that time was to modify the worker_connections parameter in the nginx configuration file nginx.conf of the proxy linux server. The value, I remembered at the time was 51200, and it was ok to change it to 4096.

Go to the linux server, open the nginx configuration file, and find that worker_connections is also 51200. After changing to 4096, restart the nginx service.

Surprise reappears, the problem is solved like this!

Summarize:

After solving it, I thought: I should adjust the error log level to debug on the linux server, and then I can see more information.
Since it is the customer's machine, there is no need to toss.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325063068&siteId=291194637