在Ec2,Ubuntu,Capistrano,Puma上的Nginx 502坏网关(连接到上游时失败(111:连接拒绝))

时间:2016-12-23 08:17:20

标签: ruby-on-rails nginx amazon-ec2 capistrano puma

愿有人帮助我!

按照本教程https://www.sitepoint.com/deploy-your-rails-app-to-aws/部署我的rails 5 app。但是在浏览器上调用应用程序时出错了。

以下是nginx日志中的错误:

2016/12/23 07:56:28 [error] 1860#1860: *149 connect() to unix:/home/deploy/my-app/shared/tmp/sockets/puma.sock 
failed (111: Connection refused) while connecting to upstream, client: 167.253.1.675, 
server: 127.0.0.1, request: "GET / HTTP/1.1", 
upstream: "http://unix:/home/deploy/my-app/shared/tmp/sockets/puma.sock:/500.html", host: "52.253.230.60"

这是我的nginx site-avalaible config:

upstream app {
# Path to Puma SOCK file, as defined previously
server unix:/home/deploy/my-app/shared/tmp/sockets/puma.sock             fail_timeout=0;
}

server {
  listen 80;
  server_name 127.0.0.1;

  root /home/deploy/my-app/current/public;

  try_files $uri/index.html $uri @app;

  location / {
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host $host;
    proxy_redirect off;
    proxy_http_version 1.1;
    proxy_set_header Connection '';
    proxy_pass http://app;
  }

  location ~ ^/(assets|fonts|system)/|favicon.ico|robots.txt {
    gzip_static on;
    expires max;
    add_header Cache-Control public;
  }

  error_page 500 502 503 504 /500.html;
  client_max_body_size 4G;
  keepalive_timeout 10;
}

这是我的config / deploy.rb:

# config valid only for current version of Capistrano
lock '3.6.1'

set :application, 'my-app'
set :repo_url, 'git@bitbucket.org:my-app/my-app.git'

#set :branch, :master
set :branch, ENV['BRANCH'] if ENV['BRANCH']
set :deploy_to, '/home/deploy/my-app'
set :pty, true
set :linked_files, %w{config/database.yml config/application.yml}
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/uploads}
set :keep_releases, 2
set :rvm_type, :user
#set :rvm_ruby_version, 'jruby-1.7.19' # Edit this if you are using MRI Ruby

set :puma_rackup, -> { File.join(current_path, 'config.ru') }
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
set :puma_pid, "#{shared_path}/tmp/pids/puma.pid"
set :puma_bind, "unix://#{shared_path}/tmp/sockets/puma.sock"          #accept array for multi-bind
set :puma_conf, "#{shared_path}/puma.rb"
set :puma_access_log, "#{shared_path}/log/puma_error.log"
set :puma_error_log, "#{shared_path}/log/puma_access.log"
set :puma_role, :app
set :puma_env, fetch(:rack_env, fetch(:rails_env, 'playground'))
set :puma_threads, [0, 8]
set :puma_workers, 0
set :puma_worker_timeout, nil
set :puma_init_active_record, true
set :puma_preload_app, false

感谢您提前!

0 个答案:

没有答案