nginx+;node.js=使用iframely连接到上游时失败

nginx+;node.js=使用iframely连接到上游时失败,node.js,nginx,Node.js,Nginx,我试着用Iframely。我在我的服务器ubuntu+nginx上安装了自托管版本: 当我像这样启动节点时: #节点服务器 Iframely工作得很好 否则,我会得到一个502坏网关错误 错误 在日志错误中: 2016/01/25 06:06:58 [error] 13265#0: *4476 connect() failed (111: Connection refused) while connecting to upstream, client: xx:xx:xx:xx:xx:xx, s

我试着用Iframely。我在我的服务器ubuntu+nginx上安装了自托管版本:

当我像这样启动节点时:
#节点服务器
Iframely工作得很好 否则,我会得到一个502坏网关错误

错误 在日志错误中:

2016/01/25 06:06:58 [error] 13265#0: *4476 connect() failed (111: Connection refused) while connecting to upstream, client: xx:xx:xx:xx:xx:xx, server: iframely.custom.com, request: "GET /iframely?url=http://coub.com/view/2pc24rpb HTTP/1.1", upstream: "http://127.0.0.1:8061/iframely?url=http://coub.com/view/2pc24rpb", host: "iframely.custom.com"
当我尝试时:
#curl-i 127.0.0.1:8061/iframely?url=http://coub.com/view/2pc24rpb

它确认了错误:
curl:(7)无法连接到127.0.0.1端口8061:连接被拒绝

我从node开始,我知道node.js可能没有监听端口8061

当我尝试时:
netstat-pantu

我看不到有问题的端口,但其他类似的端口由另一个node.js应用程序使用,它可以完美地工作:

tcp6 0 0 127.0.0.1:4567 127.0.0.1:60724已建立12329/节点

配置 我的主机配置:

upstream iframely.custom.com {
        ip_hash;
        server localhost:8061;
        keepalive 8;
}
server {

        listen 80;
        listen [::]:80;
        server_name iframely.custom.com;
        root /usr/share/nginx/html/iframely.custom.com;

        # Logs
        access_log /var/log/iframely.access_log;
        error_log /var/log/iframely.error_log;

        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://iframely.custom.com/;
                proxy_redirect off;

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

        # Exclude from the logs to avoid bloating when it's not available
        include drop.conf;

}
我曾尝试更改127.0.0.1的localhost配置,但没有任何更改

如何保持node.js应用程序的活动状态:我必须永远重新启动它吗? 这可能是ipv4或ipv6的问题吗

我在serverfault上发布了这个问题,因为我认为这是nginx配置的问题。但是有人说我错了

提前感谢您的帮助。
jb

首先,您应该使节点应用程序侦听端口8061,并且它应该显示在“netstat-tpln”中,例如:

其次,您应该使用curl测试它。如果得到响应,则节点服务器工作正常


最后,将焦点转移到nginx上。

首先,您应该让节点应用程序监听端口8061,它应该显示在“netstat-tpln”中,例如:

其次,您应该使用curl测试它。如果得到响应,则节点服务器工作正常


最后,将重点转移到nginx。

只有一个后端,使用
上游
模块没有任何好处。您可以删除
上游
部分并更新
代理通行证
行,如下所示:

    proxy_pass http://127.0.0.1:8061/;
也可能后端正在IP上侦听,但没有响应名称“localhost”。这不太可能,但有可能。但它必须监听某个IP地址,因此使用该IP地址更安全


弗拉迪斯拉夫的上述建议也很好

只有一个后端,使用
上游
模块没有任何好处。您可以删除
上游
部分并更新
代理通行证
行,如下所示:

    proxy_pass http://127.0.0.1:8061/;
也可能后端正在IP上侦听,但没有响应名称“localhost”。这不太可能,但有可能。但它必须监听某个IP地址,因此使用该IP地址更安全


弗拉迪斯拉夫的上述建议也很好

我使用永久解决问题:

我使用永久解决问题:

感谢您的测试。最后我解决了这个问题,你可以看到。谢谢你的测试。最后我解决了这个问题,你可以看到。谢谢你的回答,实际上,我使用多节点应用程序。关于我的问题,上游终于解决了。谢谢你的回答,实际上,我使用的是多节点应用程序。关于我的问题,上游似乎终于解决了。