I am attempting to deploy a meteor app to my production server, running on Ununtu 14.04 and I am getting the following error in my log file (/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"
My app is fetching json content from 5 files and these are included as part of the project.
I have the following nginx configuration file. I am running nginx 1.6.2.
I should also note that visiting http://theserver.com/content/staticContent.json loads the content in my browser.
I have also run 'wget http://127.0.0.1:3000/content/staticContent.json'
from the command line when logged into my production server and I can fetch the content.
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;
}
}
I also have the following upstart configuration file to run my Meteor App in a node fibre
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
My process for deployment is as follows:
- On my local machine I run 'meteor build .' and then scp that to my production server to the above home directory
- I then untar the .tar.gz file, cd into bundle/programs/server and run 'npm install'
- Finally, when logged in as 'anna' with sudo rights, I run 'sudo start anna' given the above upstart script
- On checking the generated log file, I see the generated html telling me there is a 502 bad gateway error.
When I go to the URL for the live website, I can see the loading icon I have put in place. This is the Meteor loading template I have put in place and I have configured IronRouter to use this as a loading template while it is waiting for the subscription to my collection to be filled, but this never happens because my server side mongodb instance never gets populated, for the reasons above.
Can anyone see anything unusual in the above that might be causing this 502 bad gateway error?
Running netstat -ln indicates to me that node.js is running, see below:
tcp 0 0 127.0.0.1:3000 0.0.0.0:* LISTEN
Thanks