-1

Nginx start throwing 499 and 502 after running fine for few days, website is a rails app using thin as the webserver. Restarting the Nginx doent not seem to help. Below the the Nginx config

Nginx config under sites-enabled

upstream domain1 {
    least_conn;
    server 127.0.0.1:3009;
    server 127.0.0.1:3010;
    server 127.0.0.1:3011;
}

server {
        listen   80; # default_server;
        server_name xyz.com *.xyz.com;
        client_max_body_size 5M;
        access_log /home/ubuntu/www/xyz/current/log/access.log;
        root   /home/ubuntu/www/xyz/current/public/;
        index  index.html;

        location / {
                      proxy_set_header  X-Real-IP  $remote_addr;
                      proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
                      proxy_set_header Host $http_host;
                      proxy_redirect off;
                      proxy_read_timeout 150;

                      if (!-f $request_filename) {
                                       proxy_pass http://domain1;
                                       break;
                      }
        }

}

  • Have you checked that all the backends are running at the ports you describe? What is the output of nginx `error.log`? What is the reason that you run three backend instances on the same server? – Tero Kilkanen Aug 23 '14 at 12:48
  • Everything seems to work fine. Just checked the error log and it says upstream timed out. There are form where images could be uploaded so have started three instances. – Abhay Kumar Aug 23 '14 at 12:59
  • Also I found this error - failed (111: Connection refused) while connecting to upstream – Abhay Kumar Aug 23 '14 at 13:06

1 Answers1

0

Some of your backend server processes have terminated, that is the reason for the 502 errors. You should study why your backend processes die, and fix the problem.

Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63
  • Thanks, I will look into the logs. Any idea on 499s which seems to be a disconnect from the client. – Abhay Kumar Aug 23 '14 at 14:45
  • 499 error code is a client disconnection. This might be due to a slow backend process, so that when the response is ready from the backend, the client has already closed the connection. – Tero Kilkanen Aug 24 '14 at 00:42