1
votes

I am deploying a rails app with nginx and unicorn and getting 502 bad getway.

Can someone help me solve this? Thank you very much

My Nginx error log (/var/log/nginx/error.log) shows:

 2015/05/14 00:26:22 [crit] 24642#0: *13 connect() to unix:/tmp/unicorn.easysign.sock failed (2: No such file or directory) while connecting to upstream, client: 89.100.32.54, server: localhost, request: "GET /easysign HTTP/1.1", upstream: "http://unix:/tmp/unicorn.easysign.sock:/500.html", host: "mysite.com"

/etc/nginx/conf.d/default.conf:

upstream app {
    # Path to Unicorn SOCK file, as defined previously
    server unix:/tmp/unicorn.easysign.sock fail_timeout=0;
}

server {
    listen 80;
    server_name localhost;

    root /var/www/mysite.com/public_html/easysign;

    try_files $uri/index.html $uri @app;

    location @app {
        proxy_pass http://app;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
    }

    error_page 500 502 503 504 /500.html;
    client_max_body_size 4G;
    keepalive_timeout 10;
}

/var/www/[app name]/config/unicorn.rb:

root = "/var/www/mysite.com/public_html/"
working_directory root
pid "#{root}/tmp/pids/unicorn.pid"
stderr_path "#{root}/log/unicorn.log"
stdout_path "#{root}/log/unicorn.log"

listen "/tmp/unicorn.easysign.sock"
worker_processes 1
timeout 30
1
Puma / Unicorn crashed... check logs, fix and restart 👍mmike

1 Answers

1
votes

Please try to change path to the socket (for example) to "/var/www/sockets/unicorn.easysign.sock". Don't forget to create "/var/www/sockets" directory. Maybe there is an issue with privileges?