(111:连接被拒绝)连接到上游时 - Opsworks Rails 4

(111:连接被拒绝)连接到上游时 - Opsworks Rails 4

我在 OpsWorks(Ubuntu 14.04、nginx 和 unicorn)中部署了一个 rails 4 应用程序,当我打开主页时,出现 502 Bad Gateway 错误。在 nginx/error.log 中我可以看到此错误:

2015/01/25 06:19:42 [error] 3652#0: *1 connect() to unix:/srv/www/app/shared/sockets/unicorn.sock failed (111: Connection refused) while connecting to upstream, client: IP, server: app$

有关更多信息,您可以查看我的 nginx.conf:

user www-data;
worker_processes  10;

error_log  /var/log/nginx/error.log;
pid        /run/nginx.pid;

events {
  worker_connections  1024;
}

http {
  include       /etc/nginx/mime.types;
  default_type  application/octet-stream;


  access_log    /var/log/nginx/access.log;

  sendfile on;
  tcp_nopush on;
  tcp_nodelay on;

  keepalive_timeout  65;

  gzip  on;
  gzip_static  on;
  gzip_http_version 1.0;
  gzip_comp_level 2;
  gzip_proxied any;
  gzip_types application/x-javascript application/xhtml+xml application/xml application/xml+rss text/css text/javascript text/plain text/xml;
  gzip_vary on;
  gzip_disable "MSIE [1-6].(?!.*SV1)";

  client_max_body_size 4m;

  server_names_hash_bucket_size 64;

  include /etc/nginx/conf.d/*.conf;
  include /etc/nginx/sites-enabled/*;

  upstream unicorn-app {
    server unix:/srv/www/app/shared/sockets/unicorn.sock fail_timeout=0;
  }

}

更新:

我为共享和套接字文件夹以及 unicorn.sock 添加了 777 权限,如您在此处所见:

drwxrwxrwx 9 部署 www-data 4096 1月25日 06:01 共享

drwxrwxrwx 2 部署 www-data 4096 1月25日 05:12 套接字

-rwxrwxrwx 1 部署 www-data 0 1月25日 05:12 unicorn.sock

但我仍然遇到同样的问题:

2015/01/26 21:19:52 [error] 3652#0: *62 connect() to unix:/srv/www/app/shared/sockets/unicorn.sock failed (111: Connection refused) while connecting to upstream, client: IP, server: app, request: "GET / HTTP/1.1", upstream: "http://unix:/srv/www/app/shared/sockets/unicorn.sock:/", host: "ec2-117.us-west-2.compute.amazonaws.com"

答案1

确保/srv/www/app/shared/sockets/unicorn.socknginx 工作进程所运行的用户具有正确的权限(www-data就您的情况而言)。

相关内容