Puma和Nginx 502错误网关错误(Ubuntu Server 14.04) [英] Puma and Nginx 502 Bad Gateway error (Ubuntu Server 14.04)

查看:98
本文介绍了Puma和Nginx 502错误网关错误(Ubuntu Server 14.04)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要部署我的rails应用程序,所以我从这里开始遵循所有步骤,

I need to deploy my rails application,So I have followed all step from here, https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-puma-and-nginx-on-ubuntu-14-04

但是在本教程结束时,我遇到了此错误->"502 Bad Gateway"

But end of the tutorial, I get this error --> "502 Bad Gateway"

编辑
现在出现错误消息->很抱歉,出了点问题."
但是Nginx错误输出是相同的,我检查了puma错误消息,但它们只是在启动时和正常停止时记录日志.

EDIT
The error message now --> "We're sorry, but something went wrong."
But Nginx error output is the same, I check puma error messages but they just log when it start and when it stop gracefully.

在app_directory/log下跟踪日志不会产生任何输出.
puma-manager->我检查了它是否正常工作
路径--->我已经检查了三遍

Rails logs which is under app_directory/log does not produce any output.
puma-manager --> I checked it works correctly
paths ---> I have checked three times

Nginx error.log输出消息:

Nginx error.log output message:

2016/05/18 14:22:21 [crit] 1099#0: *7 connect() to unix:/home/deploy   /hotel-automata/shared/sockets/puma.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.2.105, server: localhost, request: "GET /favicon.ico HTTP/1.1", upstream: "http://unix:/home/deploy/hotel-automata/shared/sockets/puma.sock:/500.html", host: "192.168.2.170"

OS-> Vmware Player,桥接网络Ubuntu Server 14.0.4
Ruby版本:2.3.1
Rails版本:4.2.5.2

OS -> Vmware Player, Bridged Network Ubuntu Server 14.0.4
Ruby Version: 2.3.1
Rails Version: 4.2.5.2

这是我的/etc/nginx/sites-available/default的Nginx配置内容

This is my nginx config contents of /etc/nginx/sites-available/default

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

server {
listen 80;
server_name localhost;

root /home/deploy/hotel-automata/public;

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

location @app {
    proxy_pass http://app;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;
}

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

推荐答案

  1. 让用户知道该套接字存在.否则,此点将失败:
  1. Make user that the socket exist. Otherwise it's failing on this point:

config/puma.rb中,您需要使行指向您的套接字:

in config/puma.rb you need to have line pointing to your socket:

bind "unix://<path or variable for the path where the socket will be>/sockets/puma.sock"

带有变量的示例:

application_path = '/home/deploy/hotel-automata/shared'

bind "unix://#{application_path}/sockets/puma.socket"

  1. 检查套接字上的权限

您需要确保Nginx能够访问您的套接字(具有必需的权限,即RW)

You will need to make sure that Nginx is able to access your socket (have the required rights i.e. RW)

检查整个路径的权限,请尝试以下操作:

The check the permissions on the whole path try this:

namei -m /home/deploy/hotel-automata/shared/sockets/puma.sock

或者尝试以下方法:

sudo -u <user> test <-r / -w > <path> && echo True

sudo -u nginx test -w /home/deploy/hotel-automata/shared/sockets/puma.sock && echo True

Nginx将需要RW访问该套接字.

如果未返回true,则表示用户未获得该权限,即-w->写入

If it doesn't return true then it means that the user has NOT got that permission i.e. -w -> write

这篇关于Puma和Nginx 502错误网关错误(Ubuntu Server 14.04)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆