Nginx配置502错误的网关错误 [英] Nginx configuration 502 bad gateway error
问题描述
我已配置/启用了运行的nginx网站:
I have a configured nginx sites enabled/available that when I run:
nginx -t
我获得了成功的测试,并且在以下时间获得了
I get a successful test and when I:
service nginx restart
thin restart -s 1
我的502错误消失了,但仅持续了十秒钟,然后再次出现.我的网站可用:
My 502 error goes away but only for ten seconds and then it shows up again. my sites-available is:
upstream myapp {
server 0.0.0.0:3000;
}
服务器{ 默认听80;
server { listen 80 default;
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;
}
}
}
有人知道为什么我的配置只能工作几秒钟吗?谢谢您的帮助,如果您需要查看其他代码,请告诉我.
Does anyone know why my config only works for a few seconds? Thank you for any help and just let me know if you need to see any of my other code.
瘦重启-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 ...
我很确定这是一个Thin问题,而不是nginx问题,因此我要发布更新.抱歉造成任何混乱.
I am pretty sure this is a Thin issue and not an nginx issue so I am posting an update. Sorry for any confusion.
我的网站运行了大约10秒钟,然后出现502 nginx错误.我的nginx配置似乎很好,并且nginx -t成功.我的错误信息是这样的:
my website is up for about 10 seconds and then I get the 502 nginx error. My nginx config seems fine and the nginx -t is successful. My error message is this:
瘦重启-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'
来自/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'
从/usr/local/lib/ruby/gems/2.0.0/gems/thin-1.5.1/lib/thin/controllers/controller.rb:92:在stop'
from /usr/local/lib/ruby/gems/2.0.0/gems/thin-1.5.1/lib/thin/runner.rb:187:in
run_command'中
来自/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
'
来自/usr/local/bin/thin:23:in load'
from /usr/local/bin/thin:23:in
'
/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'
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
'
from /usr/local/bin/thin:23:in load'
from /usr/local/bin/thin:23:in
'
我已经检查了PID,它们在那里.有人对这里发生的事情有任何想法吗?谢谢,我感谢您的任何建议.
I have checked the PID,s and they are there. Does anyone have any idea on what is going on here? thank you and I appreciate any advice.
推荐答案
我找到了运行这些细微错误所需的内容.我不知道为什么,但是运行:
I found what I needed to run to clean up those thin errors. I don't know why but running:
bundle exec thin start -p 3000
解决了我的问题.感谢大家的帮助!没有你,我找不到它.
fixed my situation. Thanks for everyone's help! I could not have found it without you.
这篇关于Nginx配置502错误的网关错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!