502 Bad Gateway, failed (13: Permission denied) - with Nginx and Unicorn

时间:2015-05-10 19:16:54

标签: ruby-on-rails azure nginx unicorn

I'm trying to deploy a rails app to azure using Nginx and Unicorn. I have been following this tutorial当我到达教程结束并启动网站时,我遇到了502错误的网关错误。在我的nginx error.log中我为每个页面加载得到这两行:

2015/05/10 19:04:37 [crit] 2784#0: *7 stat() "/var/www/offWhite/public/500.html" failed (13: Permission denied), client: 174.60.87.237, server: localhost, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/unicorn.offWhite.sock:/", host: "offfwhite.cloudapp.net"
2015/05/10 19:04:37 [crit] 2784#0: *7 connect() to unix:/tmp/unicorn.offWhite.sock failed (13: Permission denied) while connecting to upstream, client: 174.60.87.237, server: localhost, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/unicorn.offWhite.sock:/", host: "offfwhite.cloudapp.net"

我的config/unicorn.rb看起来就像教程中的那个:

# Set the working application directory
# working_directory "/path/to/your/app"
working_directory "/var/www/offWhite"

# Unicorn PID file location
# pid "/path/to/pids/unicorn.pid"
pid "/var/www/offWhite/pids/unicorn.pid"

# Path to logs
# stderr_path "/path/to/log/unicorn.log"
# stdout_path "/path/to/log/unicorn.log"
stderr_path "/var/www/offWhite/log/unicorn.log"
stdout_path "/var/www/offWhite/log/unicorn.log"

# Unicorn socket
listen "/tmp/unicorn.offWhite.sock"

# Number of processes
# worker_processes 4
worker_processes 2

# Time-out
timeout 30

我的nginx default.conf也是如此:

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

}

server {


    listen 80;
    server_name localhost;

    # Application root, as defined previously
    root /var/www/offWhite/public;

    try_files $uri/index.html $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;
    }

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

根据我在网上发现的内容,通常会出现权限问题。如果还有其他选择的话,我不想让chmod很开心。

非常感谢你

亚历

我不确定这是否应该是服务器故障。如果它应该让我知道,我会把它取下来。

编辑:

这是我每次启动服务器时在unicorn.log中获得的内容:

I, [2015-05-10T18:31:55.017694 #47698]  INFO -- : reaped #<Process::Status: pid 47701 exit 0> worker=0
I, [2015-05-10T18:31:55.017868 #47698]  INFO -- : reaped #<Process::Status: pid 47703 exit 0> worker=1
I, [2015-05-10T18:31:55.018017 #47698]  INFO -- : master complete
I, [2015-05-10T18:32:25.839675 #2048]  INFO -- : unlinking existing socket=/tmp/unicorn.offWhite.sock
I, [2015-05-10T18:32:25.840092 #2048]  INFO -- : listening on addr=/tmp/unicorn.offWhite.sock fd=10
I, [2015-05-10T18:32:25.840290 #2048]  INFO -- : worker=0 spawning...
I, [2015-05-10T18:32:25.841098 #2048]  INFO -- : worker=1 spawning...
I, [2015-05-10T18:32:25.841860 #2048]  INFO -- : master process ready
I, [2015-05-10T18:32:25.845775 #2053]  INFO -- : worker=1 spawned pid=2053
I, [2015-05-10T18:32:25.846049 #2053]  INFO -- : Refreshing Gem list
I, [2015-05-10T18:32:25.853470 #2051]  INFO -- : worker=0 spawned pid=2051
I, [2015-05-10T18:32:25.853751 #2051]  INFO -- : Refreshing Gem list
I, [2015-05-10T18:32:28.002957 #2051]  INFO -- : worker=0 ready
I, [2015-05-10T18:32:28.020675 #2053]  INFO -- : worker=1 ready

1 个答案:

答案 0 :(得分:0)

我在解决问题后几个月回答了我自己的问题,所以我没有得到我在演绎中使用的确切日志。

基本上,unicorn的日志中有一个错误,因为我从未将生产数据库声明为秘密。