【问题标题】:Nginx configuration problemsNginx 配置问题
【发布时间】:2014-06-03 03:24:58
【问题描述】:

我的 nginx 配置随机坏了。昨天我的网站还不错,今天我得到了 502 bad gateway。我的站点启用文件如下所示

upstream myapp {
    server 0.0.0.0:3000;
}

server {
    listen   80 default;

    access_log /webservices/crawler/log/access.log;
    error_log /webservices/crawler/error.log;

    root   /webservices/crawler/public/;
    index  index.html;

    client_max_body_size 500M;

    location / {
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;

        if (-f $request_filename/index.html) {
            rewrite (.*) $1/index.html;
            break;
        }

        if (-f $request_filename.html) {
            rewrite (.*) $1.html;
            break;
        }

        if (!-f $request_filename) {
            proxy_pass http://myapp;
            break;
        }
    }
}

"/etc/nginx/sites-enabled/default" 38L, 825C                                                                                   1,1           All

有人看到我需要改变什么吗?也许我的网站 IP 昨晚改变了?我只是不知道,感谢任何看的人。

【问题讨论】:

    标签: ruby-on-rails nginx configuration gateway


    【解决方案1】:

    “502 bad gateway”回答意味着“上游”网络服务器(配置中的第二行)存在问题。检查 Nginx 错误日志,您会找到原因。可能是连接错误、空回复等。

    【讨论】:

    • 谢谢,我只需要一个精简重启,那个 nginx 配置文件就好了。
    猜你喜欢
    • 2012-03-17
    • 2012-08-17
    • 1970-01-01
    • 1970-01-01
    • 2020-03-04
    • 2021-07-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多