【问题标题】:502 Bad Gateway, failed (13: Permission denied) - with Nginx and Unicorn502 Bad Gateway, failed (13: Permission denied) - 使用 Nginx 和 Unicorn
【发布时间】:2017-07-12 07:01:04
【问题描述】:

我正在尝试使用 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 日志文件中是否有任何错误?
  • 我认为没有什么不寻常的。我发布了日志文件的一部分。它只是重复,但如果有帮助,我会发布整个内容。感谢您的帮助。

标签: ruby-on-rails azure nginx unicorn


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2016-03-26
    • 2016-06-06
    • 1970-01-01
    • 2017-06-29
    • 2014-12-20
    • 2013-08-31
    • 2018-08-03
    • 2022-01-02
    • 2015-08-17
    相关资源
    最近更新 更多