Connection reset by peer and other problems

Hi guys,

I’m getting a lot of errors on logs right now and we’ve already tried
everything to solve the problem without success.
Everything was running just fine until last week.

We use nginx and php-fpm.
nginx version: nginx/1.2.0

The errors that we getting are from random pages and random domains this
is
not specific.

Here is some errors from the logs:

[error] 26002#0: 8882 readv() failed (104: Connection reset by peer)
while
reading upstream, client: XX.XXX.XX.XXX, server: www.DOMAINX.
, request:
“GET / HTTP/1.1”, upstream:
“fastcgi://unix:/var/run/php5-fpm/site_live.sock:”, host: “DOMAINX.de”,
referrer:
Redirect Notice

[error] 26002#0: 8879 recv() failed (104: Connection reset by peer)
while
reading response header from upstream, client: XX.XX.X.XX, server:
www.DOMAINX.
, request: “GET /files/2013/06/Twitter1.png HTTP/1.1”,
upstream: “fastcgi://unix:/var/run/php5-fpm/site_live.sock:”, host:
“DOMAINX.nl”

[error] 26016#0: 6433 FastCGI sent in stderr: “Primary script unknown”
while reading response header from upstream, client: 80.153.156.134,
server:
www.DOMAINX.
, request: “GET
/bezgotowkowo/conversion.php?campaignID=11759&productID=17653&conversionType=sale&descrMerchant=&descrAffiliate=&gtmcb=1675309277
HTTP/1.1”, upstream: “fastcgi://unix:/var/run/php5-fpm/site_live.sock:”,
host: “DOMAINX.pl”, referrer: “https://DOMAINX.at/order-skip

And here is is our nginx configs:

server {
listen 95;
server_name www.DOMAINX.th DOMAINX.th www.DOMAINX.se DOMAINX.se
www.DOMAINX.be DOMAINX.be;
rewrite ^ $scheme://DOMAINX.de$request_uri?;
}

server {
listen 95;
server_name www.DOMAINX.com;
rewrite ^ $scheme://DOMAINX.com$request_uri?;
}

server {
listen 95;
server_name DOMAINX.com;

access_log /site/logs/live/nginx/landing.access.log main;
error_log /site/logs/live/nginx/landing.error.log;
root /site/www/htdocs/landing.live/public/;
index index.html index.php;

port_in_redirect off;

if ($http_x_forwarded_protocol !~* ‘https’) {
return 301 https://$host$request_uri;
}

error_page 404 /redirect;
rewrite ^/redirect $scheme://$host;

location ~ .php$ {
fastcgi_pass unix:/var/run/php5-fpm/site_live.sock;
fastcgi_index index.php;
include fastcgi_params;

fastcgi_param   PHP_VALUE       "max_input_time=1200\n

memory_limit=512M\n post_max_size=128M\n upload_max_filesize=128M\n
newrelic.enabled=1\n newrelic.appname=DOMAINX.com\n
newrelic.framework=zend\n
error_log=/site/logs/live/nginx/site.error.log";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param APPLICATION_ENV live;
fastcgi_param HTTPS $thttps;
}
}

server {
listen 95;
server_name m.DOMAINX.*;

access_log /site/logs/live/nginx/mobile.access.log main;
error_log /site/logs/live/nginx/mobile.error.log;
root /site/www/htdocs/mobile.live/public/;
index index.html index.php;

port_in_redirect off;

location ~ .php$ {
fastcgi_pass unix:/var/run/php5-fpm/site_live.sock;
fastcgi_index index.php;
include fastcgi_params;

fastcgi_param   PHP_VALUE       "max_input_time=1200\n

memory_limit=512M\n post_max_size=128M\n upload_max_filesize=128M\n
newrelic.enabled=1\n newrelic.appname=mobile-live\n
newrelic.framework=zend\n
error_log=/site/logs/live/nginx/site.error.log";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param APPLICATION_ENV live;
fastcgi_param HTTPS $thttps;
}

error_page 401 /error/401.html;
error_page 403 /error/403.html;
error_page 404 /error/404.html;
error_page 500 502 503 504 /error/50x.html;

location /error {
root /var/www/default/;
}
}

server {
listen 95;
server_name developer.DOMAINX.com;

access_log /data/site/logs/live/nginx/landing.developer.access.log
main;
error_log /data/site/logs/live/nginx/landing.developer.error.log;

root /var/www/developer;
index index.html index.php;

location ~ .php$ {
fastcgi_pass unix:/var/run/php5-fpm/developer.sock;
fastcgi_index index.php;
include fastcgi_params;

fastcgi_param   PHP_VALUE       "max_input_time=1200\n

memory_limit=512M\n post_max_size=128M\n upload_max_filesize=128M\n
newrelic.enabled=1\n newrelic.appname=developer\n
error_log=/data/site/logs/live/developer.error.log";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param APPLICATION_ENV live;
fastcgi_param HTTPS $thttps;
}

error_page 401 /error/401.html;
error_page 403 /error/403.html;
error_page 404 /error/404.html;
error_page 500 502 503 504 /error/50x.html;

location /error {
root /var/www/default/;
}

}

server {
listen 95 default_server;
server_name www.DOMAINX.* DOMAINX.* site.DOMAINX.*;

access_log /site/logs/live/nginx/site.access.log main;
error_log /site/logs/live/nginx/site.error.log;

client_max_body_size 20m;
client_header_timeout 1200;
client_body_timeout 1200;
send_timeout 1200;
keepalive_timeout 1200;

set $thttps $https;
set $tscheme $scheme;
if ($http_x_forwarded_protocol = https) {
set $thttps on;
set $tscheme “https”;
}
if ($http_x_forwarded_protocol = HTTPS) {
set $thttps on;
set $tscheme “https”;
}

root /site/www/htdocs/site.live/site/public/;
try_files $uri $uri/ /index.php?$args;
index index.php;

location ^~ /files/ {
expires 864000;
fastcgi_pass unix:/var/run/php5-fpm/site_live.sock;
fastcgi_index index.php;
include fastcgi_params;

fastcgi_connect_timeout 1200;
fastcgi_send_timeout    1200;
fastcgi_read_timeout    1200;

fastcgi_param   PHP_VALUE       "max_input_time=1200\n

memory_limit=512M\n post_max_size=128M\n upload_max_filesize=128M\n
newrelic.enabled=1\n newrelic.appname=site-live\n
newrelic.framework=zend\n
error_log=/site/logs/live/nginx/site.error.log";
fastcgi_param SCRIPT_FILENAME
/site/www/htdocs/site.live/site/public/index.php$args;
fastcgi_param APPLICATION_ENV live;
fastcgi_param HTTPS $thttps;
# allow clients to cache served resources
fastcgi_param PHP_ADMIN_VALUE “session.cache_limiter = public”;
}

location ~ .php$ {
fastcgi_pass unix:/var/run/php5-fpm/site_live.sock;
fastcgi_index index.php;
include fastcgi_params;

fastcgi_connect_timeout 1200;
fastcgi_send_timeout    1200;
fastcgi_read_timeout    1200;

fastcgi_param   PHP_VALUE       "max_input_time=1200\n

memory_limit=512M\n post_max_size=128M\n upload_max_filesize=128M\n
newrelic.enabled=1\n newrelic.appname=site-live\n
newrelic.framework=zend\n
error_log=/site/logs/live/nginx/site.error.log";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param APPLICATION_ENV live;
fastcgi_param HTTPS $thttps;
# emulate ‘session.cache_limiter = nocache’ setting in “php.ini”:
fastcgi_param PHP_ADMIN_VALUE “session.cache_limiter = nocache”;
}

error_page 401 /error/401.html;
error_page 403 /error/403.html;
error_page 404 /error/404.html;
error_page 500 502 503 504 /error/50x.html;

location /error {
root /var/www/default/;
}

location /rev.txt {
access_log off;
auth_basic off;
}

set $redirect off;
if ($host ~* "DOMAINX.(.)") {
set $tld $1;
}
if ($host ~
"^www.DOMAINX.(.)") {
set $redirect on;
}
if ($host ~
"(zenpay|evopay).(.)") {
set $tld $2;
rewrite ^ $scheme://DOMAINX.$tld$request_uri? permanent;
}
if ($request_uri ~
rev.txt) {
set $redirect off;
}

if ($thttps != “on”) {
set $redirect on;
}
if ($redirect = on) {
rewrite ^ https://DOMAINX.$tld$request_uri? permanent;
}

if (-f /var/deploy/live.maintenance.lock) {
rewrite ^(.*)$ /maintenance.php break;
}

}

Thanks for your help.

Posted at Nginx Forum:

This was solved.

The problem was related with New Relic module.
2 weeks to find the problem. :frowning:

Posted at Nginx Forum:

Could you tell us how did you fix this problem?

Posted at Nginx Forum: