ruby-on-rails – Puma和Nginx 502 Bad Gateway错误(Ubuntu Server 14.04)

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – Puma和Nginx 502 Bad Gateway错误(Ubuntu Server 14.04)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我需要部署我的rails应用程序,所以我从这里开始执行所有步骤,https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-puma-and-nginx-on-ubuntu-14-04

但是教程结束时,我收到了这个错误 – > “502错误的网关”

编辑
现在出现错误消息 – > “我们很抱歉,但有些不对劲.”
但是Nginx错误输出是一样的,我检查puma错误消息,但它们只是在启动时和正常停止时记录.

app_directory / log下的Rails日志不会产生任何输出.
puma-manager – >我检查它是否正常工作
路径—>我已经检查了三次

Nginx error.log输出消息:

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

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

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;
}
编辑:

>使用户存在套接字.否则它在这一点上失败了:

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

bind "unix://

变量示例:

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

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

>检查套接字的权限

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

检查整个路径上的权限试试这个:

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

或者试试这个:

sudo -u 

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

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

如果它没有返回true,则表示用户没有获得该权限,即-w – >写

猜你在找的Nginx相关文章