使用 Thin 运行 nginx 时出错

使用 Thin 运行 nginx 时出错

我正在尝试在我的 Ubuntu 14.04 机器上安装 redmine。我已经有一个正在运行的 nginx 1.8.1 服务器,所以我需要使用它。我已经按照大量教程操作,因为我对 ruby​​ 环境没有任何经验。安装和配置好一切后,当我尝试访问 redmine 实例时,nginx 中出现错误:

2016/03/22 21:52:54 [crit] 6640#0: *253 connect() to unix:/var/sockets/thin.2.sock failed (2: No such file or directory) while connecting to upstream, client: <EDIT>, server: <EDIT>, request: "GET / HTTP/1.1", upstream: "http://unix:/var/sockets/thin.2.sock:/", host: "<EDIT>"
2016/03/22 21:52:54 [crit] 6640#0: *253 connect() to unix:/var/sockets/thin.1.sock failed (2: No such file or directory) while connecting to upstream, client: <EDIT>, server: <EDIT>, request: "GET / HTTP/1.1", upstream: "http://unix:/var/sockets/thin.1.sock:/", host: "<EDIT>"
2016/03/22 21:52:54 [crit] 6640#0: *253 connect() to unix:/var/sockets/thin.0.sock failed (2: No such file or directory) while connecting to upstream, client: <EDIT>, server: <EDIT>, request: "GET / HTTP/1.1", upstream: "http://unix:/var/sockets/thin.0.sock:/", host: "<EDIT>"

因此,我现在正在做的事情是:
1. 从三台服务器开始,如下例所示在这个网站上

$ sudo thin start -s3 --socket /var/sockets/thin.sock
Starting server on /var/sockets/thin.0.sock ...
Starting server on /var/sockets/thin.1.sock ...
Starting server on /var/sockets/thin.2.sock ...
  1. 重启 nginx

/var/sockets/目录存在,目前我已授予其 chmod 777 权限。尽管 thin 没有给出任何错误,但我看不到其中的任何 .sock 文件(也许它们是私有的?)。

另外,这是我的 nginx 主机文件:

upstream thin_cluster {
    server unix:/var/sockets/thin.0.sock;
    server unix:/var/sockets/thin.1.sock;
    server unix:/var/sockets/thin.2.sock;
    #server unix:/tmp/thin.3.sock;
    #server unix:/tmp/thin.4.sock;
}
server {
    listen       80;
    server_name  <EDIT>;

    root /usr/share/redmine/public;

    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://thin_cluster;
        break;
      }
    }

    #error_page   500 502 503 504  /50x.html;
    #location = /50x.html {
    #  root   html;
    #}
  }

答案1

它正在尝试连接到http://unix:套接字- 这可能是问题所在。看看配置设置让 nginx 修复你的配置。可能是这个

proxy_pass http://thin_cluster;

我认为 proxy_pass 只能发送到另一个 HTTP 服务器,但您尝试将其发送到 Unix 套接字。这适用于 PHP,但不适用于 proxy_pass。将其替换为

proxy_pass http://your-server-url

我不能排除其他配置错误。请尝试一下并报告结果。

相关内容