我正在尝试将流星应用程序部署到我的生产服务器,在Ununtu 14.04上运行,我在日志文件中收到以下错误(/var/log/nginx/error.log)
2014/12/02 16:03:38 [error] 19231#0: *4267 connect() failed (111: Connection refused) while connecting to upstream, client: 162.13.2.250, server: theserver.com, request: "GET /content/staticContent.json HTTP/1.1", upstream: "http://127.0.0.1:3000/content/staticContent.json", host: "theserver.com"
我的应用程序从5个文件中获取json内容,这些内容作为项目的一部分包含在内。
我有以下nginx配置文件。我正在运行nginx 1.6.2。
我还应该注意,访问http://theserver.com/content/staticContent.json会在浏览器中加载内容。
登录到我的生产服务器后,我还从命令行运行'wget http://127.0.0.1:3000/content/staticContent.json'
,我可以获取内容。
server_tokens off;
upstream anna {
server 127.0.0.1:3000;
}
# HTTP
server {
listen 80;
#server_name *.theserver.com;
server_name theserver.com;
location / {
proxy_pass http://anna;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forward-Proto http;
proxy_set_header X-NginX-Proxy true;
proxy_redirect off;
}
}
我还有以下的upstart配置文件,用于在节点光纤中运行我的Meteor App
description "Meteor.js (NodeJS) application for theserver.com"
author "Me <me@theserver.com>"
start on started mongodb and runlevel [2345]
stop on shutdown
respawn
respawn limit 10 5
setuid anna
setgid anna
script
export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
export NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript
export PWD=/home/anna
export HOME=/home/anna
export BIND_IP=127.0.0.1
export PORT=3000
export HTTP_FORWARDED_COUNT=1
export MONGO_URL=mongodb://localhost:27017/anna
export ROOT_URL=http://theserver.com/
exec node /home/anna/bundle/main.js >> /home/anna/anna.log
end script
我的部署过程如下:
当我转到实时网站的URL时,我可以看到我已经放置的加载图标。这是我已经安装的Meteor加载模板,我已经将IronRouter配置为使用它作为加载模板,同时它正在等待我的集合的订阅被填充,但这从未发生过,因为我的服务器端mongodb实例永远不会被填充,由于上述原因。
任何人都可以在上面看到任何可能导致此502错误网关错误的异常情况吗?
运行netstat -ln向我表明node.js正在运行,见下文:
tcp 0 0 127.0.0.1:3000 0.0.0.0:* LISTEN
由于
答案 0 :(得分:0)
您是否尝试过使用meteor-up?它为您处理捆绑和upstart配置。
meteor-up建议的nginx配置如下,它看起来与你的非常相似(取自Using Meteor Up with NginX vhosts)。
<强> /etc/nginx/sites-enabled/mycustomappname.com.conf 强>
server {
listen *:80;
server_name mycustomappname.com;
access_log /var/log/nginx/app.dev.access.log;
error_log /var/log/nginx/app.dev.error.log;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header X-Forwarded-For $remote_addr;
}
}