【发布时间】:2016-01-29 13:16:46
【问题描述】:
我尝试使用 iframely。我在我的服务器 ubuntu + nginx 上安装了自托管版本: https://iframely.com/docs/host
当我像这样启动节点时:
# node server
iframely 运行良好
否则,我会收到 502 bad gateway 错误。
错误
在日志错误中:
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) Failed to connect to 127.0.0.1 port 8061: Connection refused
我从 node 开始,我知道 node.js 可能没有在端口 8061 上侦听。
当我尝试时:
netstat -pantu
我没有看到有问题的端口,但其他类似的端口被另一个 node.js 应用程序使用,它运行良好:
tcp6 0 0 127.0.0.1:4567 127.0.0.1:60724 ESTABLISHED 12329/node
配置
我的主机配置:
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
【问题讨论】: