nginx 502与NodeBB的坏网关

时间:2016-01-27 17:41:53

标签: nginx nodebb

使用我的域连接到我的NodeBB安装时,我得到502坏网关 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/"

非常感谢所有帮助,我将回答所有问题,以帮助您找到解决方案,谢谢!

1 个答案:

答案 0 :(得分:0)

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

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

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

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

sudo netstat -nlp | grep ':4567'

等等,答案可能在您的日志中,这可以解释连接失败的原因:

连接到上游时

(13:权限被拒绝)

参见相关问题: