ruby-on-rails - 502 网关错误,失败 (13 : Permission denied) - with Nginx and Unicorn

标签 ruby-on-rails azure nginx unicorn

我正在尝试使用 Nginx 和 Unicorn 将 Rails 应用程序部署到 azure。我一直在关注这个tutorial当我读完教程并启动该网站时,我收到了 502 bad gateway 错误。在我的 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

最佳答案

我在解决问题几个月后才回答自己的问题,所以我没有在推论中使用的确切日志。

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

关于ruby-on-rails - 502 网关错误,失败 (13 : Permission denied) - with Nginx and Unicorn,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30155640/

相关文章:

azure - 将 Azure 流量管理器与应用服务 (HTTPS) 结合使用

nginx - 备份nginx服务器返回504

sql - Rails 查询仅在所有 has_many 关联均为 `true` 的情况下选择父记录

ruby-on-rails - 覆盖 ActiveRecord 对模型和集合的查找的最干净的方法是什么?

python-3.x - python 包未通过 CI/CD 管道安装,导入错误,找不到包

mysql - nginx-tornado-django 请求超时

Nginx stub _状态 : Ignore own requests

ruby-on-rails - 如何以编程方式调用 rails 迁移生成器?

ruby-on-rails - 如何将时间戳插入到 rails 数据库列中

azure - 如何从Azure存储资源管理器中删除表数据?