gpt4 book ai didi

ruby-on-rails - Puma 和 Nginx 502 Bad Gateway 错误(Ubuntu 服务器 14.04)

转载 作者:数据小太阳 更新时间:2023-10-29 06:50:11 26 4
gpt4 key购买 nike

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

但是在教程结束时,我得到了这个错误 --> “502 Bad Gateway”

编辑
现在的错误消息 --> “很抱歉,出了点问题。”
但是 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"

操作系统 -> 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;
}

最佳答案

编辑:

  1. 让用户知道套接字存在。否则它在这一点上失败了:

config/puma.rb 中,你需要有一条线指向你的套接字:

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)

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

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 -> write

关于ruby-on-rails - Puma 和 Nginx 502 Bad Gateway 错误(Ubuntu 服务器 14.04),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37298451/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com