Ruby on rails 轨道&x2B;独角兽&x2B;nginx连接被拒绝

Ruby on rails 轨道&x2B;独角兽&x2B;nginx连接被拒绝,ruby-on-rails,nginx,unicorn,Ruby On Rails,Nginx,Unicorn,我在my/var/log/nginx/error.log中遇到以下错误: 2014/07/08 21:55:00 [error] 1564#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 86.146.124.12, server: localstyling.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0

我在my/var/log/nginx/error.log中遇到以下错误:

2014/07/08 21:55:00 [error] 1564#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 86.146.124.12, server: localstyling.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "localstyling.com"
我在my/etc/nginx/sites中启用了一个符号链接,该符号链接到/var/www/localstyleing文件夹中的my nginx.conf:

upstream unicorn{
        server unix:/tmp/unicorn.localstyling.sock fail_timeout=0;
}

server {
  listen 80 default deferred;
  server_name localstyling.com;
  root /var/www/localstyling/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;
  }

  proxy_intercept_errors on;
  error_page 500 502 503 504 /500.html;

  client_max_body_size 100M;
  keepalive_timeout 10;
}
我有4个unicorn进程当前正在守护进程模式下运行加载它们的unicorn.rb文件是:

app_path = "/var/www/localstyling"

worker_processes 4
listen "/tmp/unicorn.localstyling.sock"
timeout 180
preload_app true
working_directory  app_path
pid "#{app_path}/tmp/pids/unicorn.pid"
stderr_path "log/unicorn.log"
stdout_path "log/unicorn.log"

before_fork do |server, worker|
  Signal.trap 'TERM' do
    puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
    Process.kill 'QUIT', Process.pid
  end

  defined?(ActiveRecord::Base) and
    ActiveRecord::Base.connection.disconnect!

  old_pid = "#{server.config[:pid]}.oldbin"
  if File.exists?(old_pid) && server.pid != old_pid
    begin
      Process.kill("QUIT", File.read(old_pid).to_i)
    rescue Errno::ENOENT, Errno::ESRCH
      puts "No process found, someone did our work for us?"
    end
  end
end

after_fork do |server, worker|
  Signal.trap 'TERM' do
    puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT'
  end

  defined?(ActiveRecord::Base) and
    ActiveRecord::Base.establish_connection
end

我不确定问题出在哪里,但我不断收到服务器的502响应,在几次小的编辑尝试后,我重新启动了nginx和unicorn,但似乎没有任何效果。

如果您尝试端口8080(在nginx之前),您的服务器是否工作?错误日志会怎么说/var/log/nginx/error.log?Ruby Race,8080已关闭,不确定你所说的“在nginx之前”是什么意思Iceman,我问题的第一部分显示了错误我有完全相同的错误,但在我的情况下,是因为unicorn停止了。重启nginx后启动unicorn解决了我的问题。