Reputation: 2974
I've read a lot of posts about fixing this, but so far nothing has worked, i'm out of ideas.
I have a Express Generator app, runs fine locally, doesn't run once on AWS Elastic Beanstalk site.
The EB runs as single instance, and the security group allows PORT 80 tcp from 0.0.0.0/0, and the rest is all default EB config (ip tables, nginx conf etc)
This is where i've got to...
1) Set node command to npm start
to ensure it runs instead of app.js
2) updated the EC2 env PATH
to add current node
/npm
to it
3) Ensured node port is running as 8081
4) checked node is actually running ok (on the box I can CURL both by IP and elastic beanstalk ULR successfully)
But from outside the box, the elastic beanstalk url returns 502 with this error..
2015/07/07 21:54:59 [error] 7883#0: *4 connect() failed (111: Connection refused) while connecting to upstream, client: 94.174.20.81, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:8081/favicon.ico", host: "ae-prod.elasticbeanstalk.com", referrer: "http://ae-prod.elasticbeanstalk.com/"
Nginx config
upstream nodejs {
server 127.0.0.1:8081;
keepalive 256;
}
server {
listen 8080;
location / {
proxy_pass http://nodejs;
proxy_set_header Connection "";
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
The IP tables on the box look like this..
$sudo iptables -t nat -L
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
REDIRECT tcp -- anywhere anywhere tcp dpt:http redir ports 8080
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
REDIRECT tcp -- anywhere anywhere tcp dpt:http redir ports 8080
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
Any one got any ideas?
Upvotes: 0
Views: 4968
Reputation: 31
I had the same issue and it turned out my node application was failing to start due to missing dependencies. Check if you have a nodejs or npm process running on the host. If not go to
/var/app/current
and try to launch your app manually via npm start
. If it throws errors on start or fails to start up these could be the reason for the 502.
Upvotes: 3