A
A
Andrey2017-09-15 16:01:30
Nginx
Andrey, 2017-09-15 16:01:30

How to solve problem 104: Connection reset by peer?

The site takes a long time to load, sometimes in the end it gives out a 502 Bad Gateway
lot of space, swap is used at 40/1024
But nginx gives an error in the logs

failed (104: Connection reset by peer) while reading response header from upstream

Tried reloading nginx, puma, killing processes.
Tell me how to solve the problem with nginx?
UPD
nginx.conf
#user  nobody;
worker_processes  1;

events {
    worker_connections  1024;
}


daemon off;
http {
gzip  on;
gzip_static on;
gzip_types text/html application/json;
include servers/*.conf;
    include       mime.types;
    default_type  application/octet-stream;


    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;

        location / {
            root   html;
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
  }
}

oil-www.conf
server {
   listen  80;
   server_name  www.example.ru;
   rewrite ^ http://example.ru$request_uri? permanent; #301 redirect
}

server{
  listen 80;
  root /home/oil/www/oil/current/apps/www/public;
  server_name example2-www.oil.ru 2016.example.ru example.ru retail.example.ru;
  client_max_body_size 50M;
  charset off;

  location ~ ^/(assets|images|system|ckeditor_assets)/  {
    root /home/oil/www/oil/current/apps/www/public;
    expires 30d;
    add_header Pragma public;
    add_header  Cache-Control public;
  }

  location / {
    try_files $uri @puma;
  }

  location @puma {
    proxy_read_timeout 18000;
    proxy_set_header  Client-Ip $remote_addr;
    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header  Host $host;
    proxy_pass  http://unix:/home/oil/www/oil/current/apps/www/tmp/sockets/puma.sock;
  }

  location /eorder6/ {
    root /home/exampleru_eorder;
  }

  location ~* /products/motul/ {
    rewrite ^ /motul_abuse redirect;
  }
  location ~* /products/motul.html {
    rewrite ^ /motul_abuse redirect;
  }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
chupasaurus, 2017-09-15
@chupasaurus

The error means that the client did not wait for a response from nginx and closed the TCP session.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question