NGINX Unicorn 504 网关超时

Ork*_*han 5 nginx ruby-on-rails unicorn

我通过这个问题尝试了我在谷歌中找到的所有内容,但是 - 什么都没有。无论如何都行不通。

我的 NGINX 默认:

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;
}
}
Run Code Online (Sandbox Code Playgroud)

NGINX 错误日志:

    *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"
Run Code Online (Sandbox Code Playgroud)

你能帮忙解决吗?

/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
Run Code Online (Sandbox Code Playgroud)

HBr*_*ijn 0

找出 nginx 之间的差异:

上游应用程序 { 服务器 unix:/tmp/unicorn. myapp .sock failed_timeout=0; }

还有你的独角兽配置:

听“ /tmp/unicorn.rails.sock ”

你可能应该将两者指向同一个套接字......

  • 套接字是否存在(`ls -l /tmp/unicorn.rails.sock`),文件系统权限是否足以让 nginx 用户访问套接字,通常需要读写 (3认同)