Rails + Puma + Nginx每两天Bad Gateway 502 [英] Rails + Puma + Nginx Every couple of days Bad Gateway 502

查看:152
本文介绍了Rails + Puma + Nginx每两天Bad Gateway 502的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Puma在Nginx上运行Rails应用程序,并且像发条一样,每隔几天该应用程序就会因502 Bad Gateway错误而关闭.

我的nginx日志包含很多这样的错误:

2015/07/23 14:43:49 [error] 14044#0: *7036 connect() to unix:///var/www/myapp/myapp_app.sock failed (111: Connection refused) while connecting to upstream, client: 12.123.12.12, server: myapp.com, request: "GET /arrangements HTTP/1.1", upstream: "http://unix:///var/www/myapp/myapp_app.sock:/arrangements", host: "myapp.com", referrer: "http://myapp.com/arrangements"

我必须重新启动Puma,并且一切都会恢复正常……几天了.

有什么想法可以解决此问题吗?我刚接触nginx和puma.

/etc/nginx/sites-enabled/myapp.com

upstream myapp {
                server unix:///var/www/myapp/myapp_app.sock;
        }
        server {
                listen 80;
                server_name myapp.com;
                root /var/www/myapp/current/public;
                client_max_body_size 20M;

                location ~ \.php$ {
                        try_files $uri =404;
                        fastcgi_pass unix:/var/run/php5-fpm.sock;
                        fastcgi_index index.php;
                        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                        include fastcgi_params;
                        allow all;
                        satisfy any;
                }

                location / {
                        proxy_pass http://myapp; # match the name of upstream directive which is defined above
                        proxy_set_header Host $host;
                        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                }
                location ~* ^/assets/ {
                        # Per RFC2616 - 1 year maximum expiry
                        expires 1y;
                        add_header Cache-Control public;

                        # Some browsers still send conditional-GET requests if there's a
                        # Last-Modified header or an ETag header even if they haven't
                        # reached the expiry date sent in the Expires header.
                        add_header Last-Modified "";
                        add_header ETag "";
                        break;
                }
        }

解决方案

DigitalOcean网络团队发现NYC3内许多网络交换机上运行的固件存在问题. 此问题导致与客户分支之间的连接中断.

虽然仅在一部分机架中确认了该问题,但我们将升级在NYC3中运行受影响的固件的所有交换机.升级单个交换机后,在维护时段内的某个时间点,此维护将导致每个机架的停机时间约为十分钟.

维护窗口: 2015-08-27 22:00 EDT-2015-08-28 02:00 EDT 2015-08-28 02:00 UTC-2015-08-28 06:00 UTC

对于给您带来的不便,我们深表歉意,感谢您在我们提高网络可靠性方面的耐心等待.


我要花一两天的时间,看看您遇到的问题是否再次发生,或者只是自行消失.

添加/编辑

P.S.我刚刚在电子邮件中注意到了一个细节,

受影响的液滴: railsbox00

如果您收到电子邮件,则说明您的Droplet受固件问题影响.检查您的电子邮件,看看它们是否列出了您的VPS;在电子邮件的底部.

I have a rails app running on Nginx with Puma and like clockwork, every couple of days the app goes down with a 502 Bad Gateway error.

My nginx log contains lots of errors like this:

2015/07/23 14:43:49 [error] 14044#0: *7036 connect() to unix:///var/www/myapp/myapp_app.sock failed (111: Connection refused) while connecting to upstream, client: 12.123.12.12, server: myapp.com, request: "GET /arrangements HTTP/1.1", upstream: "http://unix:///var/www/myapp/myapp_app.sock:/arrangements", host: "myapp.com", referrer: "http://myapp.com/arrangements"

I have to restart Puma and everything works again...for a couple days.

Any ideas how I can troubleshoot this? I'm newer to nginx and puma.

/etc/nginx/sites-enabled/myapp.com

upstream myapp {
                server unix:///var/www/myapp/myapp_app.sock;
        }
        server {
                listen 80;
                server_name myapp.com;
                root /var/www/myapp/current/public;
                client_max_body_size 20M;

                location ~ \.php$ {
                        try_files $uri =404;
                        fastcgi_pass unix:/var/run/php5-fpm.sock;
                        fastcgi_index index.php;
                        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                        include fastcgi_params;
                        allow all;
                        satisfy any;
                }

                location / {
                        proxy_pass http://myapp; # match the name of upstream directive which is defined above
                        proxy_set_header Host $host;
                        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                }
                location ~* ^/assets/ {
                        # Per RFC2616 - 1 year maximum expiry
                        expires 1y;
                        add_header Cache-Control public;

                        # Some browsers still send conditional-GET requests if there's a
                        # Last-Modified header or an ETag header even if they haven't
                        # reached the expiry date sent in the Expires header.
                        add_header Last-Modified "";
                        add_header ETag "";
                        break;
                }
        }

解决方案

The DigitalOcean network team has identified an issue with firmware running on a number of network switches within NYC3. This issue is causing intermittent loss of connectivity to customer droplets.

While the issue has been confirmed only in a subset of racks, we will be upgrading all switches running the affected firmware in NYC3. This maintenance will result in approximately ten minutes of downtime per rack at some point within the maintenance window as individual switches are upgraded.

Maintenance window: 2015-08-27 22:00 EDT - 2015-08-28 02:00 EDT 2015-08-28 02:00 UTC - 2015-08-28 06:00 UTC

We apologize for the inconvenience and appreciate your patience as we work to improve the reliability of our network.


I would give it a day or two and see if the problem you're having recurs, or simply disappears on its own.

Added/Edited

P.S. I just noticed a detail on the email,

Affected Droplets: railsbox00

if you're getting the e-mails, then your droplet is affected by the firmware problem. Check your emails and see if they list your VPS; it's at the bottom of the email.

这篇关于Rails + Puma + Nginx每两天Bad Gateway 502的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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