Nginx 无法连接到瘦服务器

问题描述

我在新配置的服务器上的 rails 应用程序出现 Nginx 502 错误,相同的 Nginx 配置适用于运行相同应用程序的其他服务器 /tmp/thin.2.sock 文件在我启动应用程序时被正确创建并且我的应用程序在后台正常运行

Nginx 错误日志:

2021/01/25 13:34:30 [crit] 1966#0: *49 connect() to unix:/tmp/thin.2.sock Failed (2: No such file or directory) while connecting to upstream,client: XX.XXX.X.XXX,server: domain.com,request: "GET / HTTP/1.1",upstream: "http://unix:/tmp/thin.2.sock:/",host: "domain.com"

Nginx 配置文件

upstream  appuser{
       server   unix:/tmp/thin.0.sock;
       server   unix:/tmp/thin.1.sock;
       server   unix:/tmp/thin.2.sock;
    }

server {
        listen       80 ;
        server_name  domain.com;
        root         /home/appuser/app_name/public;
        access_log   /home/appuser/app_name/log/access.log;
        error_log    /home/appuser/app_name/log/error.log;
        index        index.html;

        gzip            on;
        gzip_comp_level 3;
        gzip_types      text/plain text/css application/javascript image/*;

                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;
                 try_files /system/maintenance.html $uri $uri/index.html $uri.html @ruby;
                 client_max_body_size 6m;
             }

              location @ruby {
                  proxy_pass http://appuser;
              }

        }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)