Nginx配置502坏网关错误

时间:2014-05-01 21:38:43

标签: ruby-on-rails nginx

我运行时已启用/可用已配置的nginx网站:

nginx -t

我得到了一个成功的测试,当我:

service nginx restart
thin restart -s 1

我的502错误消失但只持续了十秒钟,然后再次出现。我的网站可用:

upstream myapp {
server 0.0.0.0:3000;

}

服务器{     听80默认;

access_log /webservices/crawler/log/access.log;
error_log /webservices/crawler/error.log;

root   /webservices/crawler/public/;
index  index.html;

client_max_body_size 500M;

location / {
    proxy_set_header  X-Real-IP  $remote_addr;
    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;

    if (-f $request_filename/index.html) {
        rewrite (.*) $1/index.html;
        break;
    }

    if (-f $request_filename.html) {
        rewrite (.*) $1.html;
        break;
    }

    if (!-f $request_filename) {
        proxy_pass http://myapp;
        break;
    }
}

}

有谁知道为什么我的配置只能工作几秒钟?感谢您的帮助,如果您需要查看我的其他任何代码,请告诉我。

thin restart -s 2输出:

    /# thin restart -s 2
Stopping server on 0.0.0.0:3000 ... 
/usr/local/lib/ruby/gems/2.0.0/gems/thin-1.5.1/lib/thin/daemonizing.rb:131:in `send_signal': Can't stop process, no PID found in tmp/pids/thin.3000.pid (Thin::PidFileNotFound)
    from /usr/local/lib/ruby/gems/2.0.0/gems/thin-1.5.1/lib/thin/daemonizing.rb:113:in `kill'
    from /usr/local/lib/ruby/gems/2.0.0/gems/thin-1.5.1/lib/thin/controllers/controller.rb:93:in `block in stop'
    from /usr/local/lib/ruby/gems/2.0.0/gems/thin-1.5.1/lib/thin/controllers/controller.rb:134:in `tail_log'
    from /usr/local/lib/ruby/gems/2.0.0/gems/thin-1.5.1/lib/thin/controllers/controller.rb:92:in `stop'
    from /usr/local/lib/ruby/gems/2.0.0/gems/thin-1.5.1/lib/thin/runner.rb:187:in `run_command'
    from /usr/local/lib/ruby/gems/2.0.0/gems/thin-1.5.1/lib/thin/runner.rb:152:in `run!'
    from /usr/local/lib/ruby/gems/2.0.0/gems/thin-1.5.1/bin/thin:6:in `<top (required)>'
    from /usr/local/bin/thin:23:in `load'
    from /usr/local/bin/thin:23:in `<main>'
Stopping server on 0.0.0.0:3001 ... 
/usr/local/lib/ruby/gems/2.0.0/gems/thin-1.5.1/lib/thin/daemonizing.rb:131:in `send_signal': Can't stop process, no PID found in tmp/pids/thin.3001.pid (Thin::PidFileNotFound)
    from /usr/local/lib/ruby/gems/2.0.0/gems/thin-1.5.1/lib/thin/daemonizing.rb:113:in `kill'
    from /usr/local/lib/ruby/gems/2.0.0/gems/thin-1.5.1/lib/thin/controllers/controller.rb:93:in `block in stop'
    from /usr/local/lib/ruby/gems/2.0.0/gems/thin-1.5.1/lib/thin/controllers/controller.rb:134:in `tail_log'
    from /usr/local/lib/ruby/gems/2.0.0/gems/thin-1.5.1/lib/thin/controllers/controller.rb:92:in `stop'
    from /usr/local/lib/ruby/gems/2.0.0/gems/thin-1.5.1/lib/thin/runner.rb:187:in `run_command'
    from /usr/local/lib/ruby/gems/2.0.0/gems/thin-1.5.1/lib/thin/runner.rb:152:in `run!'
    from /usr/local/lib/ruby/gems/2.0.0/gems/thin-1.5.1/bin/thin:6:in `<top (required)>'
    from /usr/local/bin/thin:23:in `load'
    from /usr/local/bin/thin:23:in `<main>'
Starting server on 0.0.0.0:3000 ... 
Starting server on 0.0.0.0:3001 ... 

我很确定这是一个瘦问题而不是nginx问题所以我发布了一个更新。抱歉有任何困惑。

我的网站启动了大约10秒,然后我得到502 nginx错误。我的nginx配置似乎很好,nginx -t成功。我的错误信息是:

thin restart -s 5

/usr/local/lib/ruby/gems/2.0.0/gems/thin-1.5.1/lib/thin/daemonizing.rb:131:in send_signal': Can't stop process, no PID found in tmp/pids/thin.3004.pid (Thin::PidFileNotFound) from /usr/local/lib/ruby/gems/2.0.0/gems/thin-1.5.1/lib/thin/daemonizing.rb:113:in kill&#39;     来自/usr/local/lib/ruby/gems/2.0.0/gems/thin-1.5.1/lib/thin/controllers/controller.rb:93:in block in stop' from /usr/local/lib/ruby/gems/2.0.0/gems/thin-1.5.1/lib/thin/controllers/controller.rb:134:in tail_log&#39;     来自/usr/local/lib/ruby/gems/2.0.0/gems/thin-1.5.1/lib/thin/controllers/controller.rb:92:in stop' from /usr/local/lib/ruby/gems/2.0.0/gems/thin-1.5.1/lib/thin/runner.rb:187:in run_command&#39;     来自/usr/local/lib/ruby/gems/2.0.0/gems/thin-1.5.1/lib/thin/runner.rb:152:in run!' from /usr/local/lib/ruby/gems/2.0.0/gems/thin-1.5.1/bin/thin:6:in&#39;     来自/ usr / local / bin / thin:23:load' from /usr/local/bin/thin:23:in&#39;

我检查过PID,他们在那里。有没有人知道这里发生了什么?谢谢你,我感谢任何建议。

1 个答案:

答案 0 :(得分:0)

我找到了运行清理那些细小错误所需要的东西。我不知道为什么,但跑步:

bundle exec thin start -p 3000

修复了我的情况。谢谢大家的帮助!没有你,我无法找到它。