5

I try all what I found in the Google by this question, but - nothing. It doesn't work anyway.

My NGINX default:

upstream app {
    server unix:/tmp/unicorn.rails.sock fail_timeout=0;
}

server {
    listen   80;
    root /home/rails/public;
    server_name _;
    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;
}
}

NGINX Error log:

    *12 connect() to unix:/tmp/unicorn.myapp.sock failed (2: No such file or directory) while connecting to upstream, client: 46.228.180.65, server: _, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/unicorn.myapp.sock:/", host: "178.62.102.154"

Can you help to fix it?

/home/rails/config/unicorn.rb

working_directory "/home/rails"
pid "/home/rails/pids/unicorn.pid"
stderr_path "/home/rails/log/unicorn.log"
stdout_path "/home/rails/log/unicorn.log"
listen "/tmp/unicorn.rails.sock"
worker_processes 2
timeout 30
Orkhan
  • 59
  • 3

1 Answers1

0

Spot the differences between nginx:

upstream app { server unix:/tmp/unicorn.myapp.sock fail_timeout=0; }

And your unicorn configuration:

listen "/tmp/unicorn.rails.sock"

You should probably point both to the same socket...

HBruijn
  • 72,524
  • 21
  • 127
  • 192
  • No. Nothing. The same error: `connect() to unix:/tmp/unicorn.rails.sock failed (2: No such file or directory` – Orkhan Jan 30 '15 at 09:18
  • 3
    And does the socket exist (`ls -l /tmp/unicorn.rails.sock`) and are the file system permissions sufficient for the nginx user to access the socket, read-write is typically needed – HBruijn Jan 30 '15 at 09:22