【问题标题】:nginx 502 Bad Gateway with NodeBB带有 NodeBB 的 nginx 502 错误网关
【发布时间】:2016-01-27 17:41:53
【问题描述】:

使用我的域连接到我的 NodeBB 安装时,我得到 502 bad gateway NodeBB 在默认端口 (4567) 上运行

我的 nginx 似乎配置正确(使用 IP 连接时):http://puu.sh/mLI7U/0e03691d4c.png 我的 nodebb 似乎配置正确(使用 IP 连接时): http://puu.sh/mLI95/5fdafcaed9.png 我的 A 记录将 IP 定向到我的 VPS 配置正确。

这是我的 etc/nginx/conf.d/example.com.conf

server {
listen 80;

server_name sporklounge.com;

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_set_header X-NginX-Proxy true;

    proxy_pass http://127.0.0.1:4567/;
    proxy_redirect off;

    # Socket.IO Support
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}

}

My NodeBB config.json
{
    "url": "http://localhost:4567",
    "secret": "25d0d6a2-0444-49dc-af0c-bd693f5829d8",
    "database": "redis",
    "redis": {
        "host": "127.0.0.1",
        "port": "6379",
        "password": "",
        "database": "0"
    }
}

这是我的 var/log/nginx/error.log

    2016/01/27 12:04:42 [error] 22026#0: *4062 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 50.186.224.26, server: sporklounge.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:80/favicon.ico", host: "sporklounge.com", referrer: "http://sporklounge.com/"
2016/01/27 12:21:06 [crit] 974#0: *1 connect() to 127.0.0.1:4567 failed (13: Permission denied) while connecting to upstream, client: 50.186.224.26, server: sporklounge.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:4567/", host: "sporklounge.com"
2016/01/27 12:21:07 [crit] 974#0: *1 connect() to 127.0.0.1:4567 failed (13: Permission denied) while connecting to upstream, client: 50.186.224.26, server: sporklounge.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:4567/favicon.ico", host: "sporklounge.com", referrer: "http://sporklounge.com/"

非常感谢所有帮助,我将回答所有我能帮助获得解决方案的问题,谢谢!

【问题讨论】:

    标签: nginx nodebb


    【解决方案1】:

    我看到的一件事是,根据the docs,您的url 配置值应该是指向您的NodeBB 的完整Web 可访问地址。那将是sporklounge.com,而不是当前值。

    也可能是后端有时响应缓慢。在 Nginx 中尝试非常高的值,看看后端是否最终响应:

     # For testing, allow very long response times.
     proxy_read_timeout 5m;
    

    另外,使用 netstat 确认后端正在端口 4567 上运行:

    sudo netstat -nlp | grep ':4567'
    

    等等,答案可能在你的日志中,这会告诉你连接失败的原因:

    (13:权限被拒绝)同时连接到上游

    查看相关问题:

    【讨论】:

    • 权限被拒绝的帖子解决了我的问题。非常感谢!
    猜你喜欢
    • 2019-12-04
    • 2020-06-29
    • 1970-01-01
    • 2011-05-14
    • 2019-06-05
    • 2015-08-10
    • 1970-01-01
    • 2016-01-22
    • 2021-11-19
    相关资源
    最近更新 更多