Why I'm getting frequent 504 Time out error?

389 Views Asked by At

my nginx configuration is as:

upstream app_server {
        server unix:/run/DigitalOceanOneClick/unicorn.sock fail_timeout=0;
    }

    server {
        listen   80;
        root /home/rails/rails_project/public;
        server_name example.com www.example.com;
        index index.htm index.html;

        location / {
                try_files $uri/index.html $uri.html $uri @app;
        }

        location ~* ^.+\.(jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|mp3|flv|mpeg|avi)$ {
                        try_files $uri @app;
                }

         location @app {
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $http_host;
                proxy_redirect off;
                proxy_pass http://app_server;
                proxy_read_timeout 180;
                proxy_http_version 1.1;
                proxy_set_header Connection "";
        }
    }  

And unicorn configuration file is as:

listen "unix:/run/DigitalOceanOneClick/unicorn.sock"
worker_processes 4
user "rails"
working_directory "/home/rails/rails_project"
pid "/run/DigitalOceanOneClick/unicorn.pid"
stderr_path "/var/log/unicorn/unicorn.log"
stdout_path "/var/log/unicorn/unicorn.log"  

I'm getting "504 Gateway Time-out" error frequently. I'm not getting any idea about the problem. Server OS is Ubuntu 14.04 with rails5.1.3, nginx and unicorn. Thank you.

0

There are 0 best solutions below