Php5-fpm + nginx + google bot = connection reset by peer

So, I just had an hour of nuts trying to understand why my logs with slow php script warned about errors literally several times per minute over the past few hours.

Initially, I focused on slow php logs and php error logs, thinking that this is my code. It just happened that I was doing some DNS settings, so I was driven off the wrong path.

In the end, I checked the nginx error log, which showed the line after the reset connection string from the peer from approximately the same IP address.

I googled the IP addresses and found that it belongs to Google, so this is clearly a google bot / spider visiting the site.

Here is the error log clip

2013/06/06 14:04:05 [error] 12313#0: *7435269 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 209.85.238.187, server: www.domain.com, request: "GET /c.html?q=xyz HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.domain.com" 2013/06/06 14:04:05 [error] 12308#0: *7435135 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 209.85.238.167, server: www.domain.com, request: "GET /c.html?q=xyz HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.domain.com" 2013/06/06 14:04:05 [error] 12308#0: *7435994 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 209.85.238.199, server: www.domain.com, request: "GET /c.html?q=xyz HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.domain.com" 2013/06/06 14:04:12 [error] 12309#0: *7436209 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 209.85.238.168, server: www.domain.com, request: "GET /c.html?q=xyz HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.domain.com" 2013/06/06 14:05:12 [error] 12309#0: *7441608 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 209.85.238.177, server: www.domain.com, request: "GET /c.html?q=xyz HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.domain.com" 2013/06/06 14:05:15 [error] 12310#0: *7440634 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 209.85.238.219, server: www.domain.com, request: "GET /c.html?q= xyz HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.domain.com" 2013/06/06 14:05:15 [error] 12313#0: *7441634 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 209.85.238.194, server: www.domain.com, request: "GET /c.html?q=xyz HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.domain.com" 2013/06/06 14:06:02 [error] 12310#0: *7444721 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 209.85.238.221, server: www.domain.com, request: "GET /c.html?q=xyz HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.domain.com" 2013/06/06 14:06:05 [error] 12308#0: *7443911 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 209.85.238.203, server: www.domain.com, request: "GET /c.html?q=xyz HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.domain.com" 2013/06/06 14:06:05 [error] 12309#0: *7445423 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 209.85.238.164, server: www.domain.com, request: "GET /c.html?q=xyz HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.domain.com" 2013/06/06 14:06:05 [error] 12310#0: *7445640 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 209.85.238.222, server: www.domain.com, request: "GET /c.html?q=xyz HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.domain.com" 

What is the reason for connecting reset from a peer. Will the google bot really visit the page and complete the request, just to verify that it is alive?

This is not very pleasant, because it calls my perm requests, which then belong to the orphan thread, because the client left it. This means that they simply fail, causing slow php scripts.

Or did I read it wrong?

+6
source share
1 answer

If you see the error message, it indicates

while reading the response header upstream

This means that the problem is not that Google completes the request, but rather that nginx upstream, which happens to be php-fpm, completes the request. This is usually caused by an error in running php code.

Given we don’t have code, here are some general troubleshooting steps:

  • In the php-fpm configuration, increase the request_terminate_timeout , max_input_time and max_execution_time values.
  • Activate error logging in php.ini or pool .conf configuration files (but not "display_error" if this is a website).
  • Try running the debugger in the current code (xdebug is very useful) to go through the code and you will come across most of the problems.
0
source

Source: https://habr.com/ru/post/946716/


All Articles