关键词:
【中文标题】Puma 和 Nginx 502 Bad Gateway 错误(Ubuntu Server 14.04)【英文标题】:Puma and Nginx 502 Bad Gateway error (Ubuntu Server 14.04) 【发布时间】:2016-09-14 20:55:08 【问题描述】:我需要部署我的 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 红宝石版本: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;
【问题讨论】:
我对彪马一无所知。但是您是否尝试过更改puma.sock
文件的权限?当我将uwsgi
与nginx
一起使用时,我曾经遇到过这种错误
发布你的 nginx 配置
@dan-klasson 我已经添加了 nginx 配置
@manojprashantk 目录中没有 puma.sock 文件。
我可能错了,但你能不能把unix:/home/deploy/hotel-automata/shared/sockets/puma.sock
改成unix:///home/deploy/hotel-automata/shared/sockets/puma.sock
试试
【参考方案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"
-
检查套接字的权限
您需要确保 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
【讨论】:
我的套接字路径没有间隙,你的意思是不同的吗? 在您提供新数据时必须编辑我的答案,检查权限并告诉我。 目录下没有puma.sock文件。它应该自动生成吗? @MichaIT 当 puma 启动它应该创建一个套接字。这是你配置它的地方:vi config/puma.rb
# Set up socket location bind "unix://#shared_dir/sockets/puma.sock"
只要确保在config/puma.rb
中你有bind "unix://<path to your socket>/sockets/puma.sock"
然后重启你的puma。很难让某人通过评论框。我会再次编辑答案【参考方案2】:
您的puma.rb
文件应如下所示。
# /config/puma.rb
app = "manabalss" # App-specific
root = "/home/deployer/apps/#app"
workers 5
threads 1, 1 # relying on many workers for thread-unsafe apps
rackup DefaultRackup
port 11592
environment ENV['RACK_ENV'] || 'production'
daemonize true
pidfile "#root/puma/puma.pid"
stdout_redirect "#root/puma/puma.log", "#root/puma/puma_error.log"
bind "unix:/tmp/puma.socket
而你的 nginx.conf 应该是这样的。
# config/deploy/nginx.conf
upstream puma
server unix:/tmp/puma.socket fail_timeout=1;
# This block redirects http requests to https version
server
listen 37.139.0.211:80 default deferred;
server_name www.manabalss.lv, manabalss.lv;
return 307 https://manabalss.lv$request_uri;
server
listen 37.139.0.211:443 ssl;
server_name manabalss.lv;
ssl_certificate /etc/ssl/server.crt;
ssl_certificate_key /etc/ssl/server.key;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers RC4:HIGH:!aNULL:!MD5;
ssl_session_cache shared:SSL:15m;
ssl_session_timeout 15m;
root /home/deployer/apps/manabalss/current/public;
location ^~ /assets/
gzip_static on;
gzip_vary on;
expires max;
add_header Cache-Control public;
try_files $uri/index.html $uri @puma;
location @puma
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://puma;
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
如果这没有帮助,你想看看这个。
Rails + Puma + Nginx Every Bad Gateway 502
【讨论】:
谢谢subhash,我现在开始尝试运行 Puma 和 Nginx 的带有 AWS Elastic Beanstalk 的 Rails 应用程序 502
】运行Puma和Nginx的带有AWSElasticBeanstalk的Rails应用程序502【英文标题】:Railsapp502withAWSElasticBeanstalkrunningPuma&Nginx【发布时间】:2014-07-0502:05:52【问题描述】:我已经能够成功地让我的应用程序在Beanstalk上与Passenger一起运行,但... 查看详情
使用 -d(守护进程)运行 Rails(Puma)时的 Nginx 502
】使用-d(守护进程)运行Rails(Puma)时的Nginx502【英文标题】:Nginx502whenrunningRails(Puma)with-d(daemon)【发布时间】:2019-11-1704:05:22【问题描述】:Ruby2.5.1,Rails5.2.2.1我正在尝试让nginx通过puma套接字进入上游。当我运行railss-eproduction... 查看详情
Nginx 渲染 502 错误页面
】Nginx渲染502错误页面【英文标题】:Nginxrendering502errorpage【发布时间】:2016-04-1601:27:07【问题描述】:我正在尝试使用puma配置nginx来为我的RubyonRails应用程序提供服务。每当我访问我的页面时,都会收到502badgateway错误。/etc/nginx/... 查看详情
使用 flask_socketio + flask + gunicorn + nginx 获得 502 bad gateway 和 400 bad request
】使用flask_socketio+flask+gunicorn+nginx获得502badgateway和400badrequest【英文标题】:Getting502badgatewayand400badrequestwithflask_socketio+flask+gunicorn+nginx【发布时间】:2020-11-2823:26:21【问题描述】:所以我一直在用flask+flask_socketio+eventlet+gu 查看详情
调试 502 Bad Gateway 错误 - Ubuntu、Nginx、Unicorn
】调试502BadGateway错误-Ubuntu、Nginx、Unicorn【英文标题】:Debugging502BadGatewayerror-Ubuntu,Nginx,Unicorn【发布时间】:2017-06-2904:37:29【问题描述】:我有一个EC2实例,正在尝试使用Nginx和Unicorn运行Rails应用程序。大约60秒后,我不断收到502... 查看详情
为啥我在使用 Nginx 和 Gunicorn 的 Django 应用程序上得到 502 Bad Gateway?
】为啥我在使用Nginx和Gunicorn的Django应用程序上得到502BadGateway?【英文标题】:WhyamIgetting502BadGatewayonDjangoappwithNginxandGunicorn?为什么我在使用Nginx和Gunicorn的Django应用程序上得到502BadGateway?【发布时间】:2017-01-0411:18:21【问题描述... 查看详情
带有 Daphne 的 Nginx 给出 502 Bad Gateway
】带有Daphne的Nginx给出502BadGateway【英文标题】:NginxwithDaphnegives502BadGateway【发布时间】:2019-08-1403:45:48【问题描述】:我决定用daphne替换uwsgi,因为我遇到了DjangoChannels和uwsgi的问题。在遵循this教程之后。我在启用站点的情况下... 查看详情
如何解决这个错误 Nginx and uwsgi 502 bad gateway
】如何解决这个错误Nginxanduwsgi502badgateway【英文标题】:HowtosolvethiserrorNginxanduwsgi502badgateway【发布时间】:2017-02-0509:36:58【问题描述】:我遇到了502BadGateway错误。如何解决?我抓到了nginx访问日志和错误日志访问日志120.142.184.164-... 查看详情
使用 Docker-Compose 和 nginx-proxy 时出现 502 Bad Gateway 错误
】使用Docker-Compose和nginx-proxy时出现502BadGateway错误【英文标题】:502BadGatewayerrorusingDocker-Composeandnginx-proxy【发布时间】:2016-10-2309:57:04【问题描述】:我是nginx新手,正在尝试使用Docker-Compose设置链接的DOcker容器。根据教程here和jw... 查看详情
尝试在 Docker 上使用 NGINX + Gunicorn 时 NGINX 给出 502 Bad Gateway
】尝试在Docker上使用NGINX+Gunicorn时NGINX给出502BadGateway【英文标题】:NGINGXgives502BadGatewaywhentryingtouseNGINX+GunicornonDocker【发布时间】:2018-10-3001:27:50【问题描述】:我正在开发一个带有PostgreSQL数据库的Django应用程序,并且我正在使... 查看详情
我的 ROR+Nginx+Passenger+AWS 正在发送 502 bad gateway
】我的ROR+Nginx+Passenger+AWS正在发送502badgateway【英文标题】:MyROR+Nginx+Passenger+AWSissending502badgateway【发布时间】:2017-07-1122:06:32【问题描述】:我正在使用ROR+Nginx+passenger和AmazonWeb服务开发android服务。服务器运行良好,但昨天服务... 查看详情
asp.net core 3.0 上的 502 Bad Gateway 托管在 ubuntu 18.04 TLS 和 nginx
】asp.netcore3.0上的502BadGateway托管在ubuntu18.04TLS和nginx【英文标题】:502BadGatewayonasp.netcore3.0hostedinubuntu18.04TLSwithnginx【发布时间】:2020-05-1321:44:47【问题描述】:我使用nginx将.NETCORE应用程序发布到ubuntu18.04TLS,但是当我尝试浏览时... 查看详情
服务器域返回 502 Bad Gateway - Nginx
】服务器域返回502BadGateway-Nginx【英文标题】:Serverdomainreturning502BadGateway-Nginx【发布时间】:2021-09-1123:46:11【问题描述】:我无法通过域名访问我的服务器。它显示502BadGateway。显示SSL_do_handshake()失败的错误日志。但是当我通过ip... 查看详情
Django Nginx uWSGI 502 Bad Gateway 总是
】DjangoNginxuWSGI502BadGateway总是【英文标题】:DjangoNginxuWSGI502BadGatewayalways【发布时间】:2017-03-1310:03:22【问题描述】:我一直在关注http://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html然后走到了http://uwsgi-docs.readthedocs 查看详情
Nginx 用 502 Bad Gateway 覆盖一般的 symfony 错误
】Nginx用502BadGateway覆盖一般的symfony错误【英文标题】:Nginxoverwritesgeneralsymfonyerrorswith502BadGateway【发布时间】:2013-07-1611:59:43【问题描述】:当我尝试访问不存在的路由或在Twig模板中出错时,我没有得到带有调试信息的Symfony错... 查看详情
用于magento应用程序的502 Bad Gateway nginx
】用于magento应用程序的502BadGatewaynginx【英文标题】:502BadGatewayngnixformagentoapplication【发布时间】:2014-08-0405:34:36【问题描述】:很多次我浏览Magento网站,我在Nginx收到502badgateway错误。!在此错误页面加载之前需要89秒。screenshotN... 查看详情
如何最好地管理 AWS 中的 Cloudfront/Nginx 502 Bad Gateway 错误
】如何最好地管理AWS中的Cloudfront/Nginx502BadGateway错误【英文标题】:HowbesttomanageCloudfront/Nginx502BadGatewayerrorsinAWS【发布时间】:2021-01-2214:40:13【问题描述】:我们有一个通过CloudFront提供服务的网站。本周某个时候,源EC2(ECS)服务器... 查看详情
当代理服务器关闭时,NGINX 反向代理返回 502 bad gateway
】当代理服务器关闭时,NGINX反向代理返回502badgateway【英文标题】:NGINXReverseProxyreturn502badgatewaywhenproxiedserverisdown【发布时间】:2016-01-1707:41:37【问题描述】:我将nginx设置为我的apachetomcat的反向代理。它按我的预期正常工作。... 查看详情