简体   繁体   中英

502 Bad Gateway - Meteor and nginx on Ubuntu 16.04.2 LTS

I have a problem installing my Meteor / NodeJS website on my Ubuntu 16.04.2 LTS server with Nginx.

I wanted to follow the following article How To Deploy a Meteor.js Application on Ubuntu 14.04 with Nginx (Digital Ocean), as it is not up to date I also watch this one www.medium.com/@jaaaco/run-meteor-app-as-a-service-on-ubuntu-c4aa1153408a#.bn9q49h1w

systemd :

 [Service] ExecStart=/usr/bin/node /home/dezeiraud/bundle/main.js Restart=always StandardOutput=syslog StandardError=syslog SyslogIdentifier=dezeiraud User=dezeiraud Group=dezeiraud Environment=NODE_ENV=production Environment=PWD=/home/dezeiraud Environment=PORT=8080 Environment=HTTP_FORWARDED_COUNT=1 Environment=ROOT_URL=http://dezeiraud.com Environment='METEOR_SETTINGS={"someSetting": "someValue"}' [Install] WantedBy=multi-user.target 

It looks to work well (see image below).

systemclt status

Ngnix :

 server_tokens off; # for security-by-obscurity: stop displaying nginx version # we're in the http context here map $http_upgrade $connection_upgrade { default upgrade; '' close; } # the Meteor / Node.js app server server { listen 80; server_name dezeiraud.com; access_log /etc/nginx/logs/dezeiraud.access; error_log /etc/nginx/logs/dezeiraud.error error; location / { proxy_pass http://127.0.0.1:8080; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_http_version 1.1; # WebSocket proxying proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; add_header Cache-Control no-cache; } } 

And here the configuration of nginx. The error file contains the following text :

failed (111: Connection refused)

nginx error file

It's going to be several hours since I'm looking for a solution, and my research on the internet is not conclusive ... I guess the error is absurd but I can not find it.

Thank you for your time. Best Regards. (Sorry for my bad English)

I had a similar problem and it had to do with the port on which meteor was running, so i changed the port from 8080 to 3000 (3000 was the port meteor runs on by default i believe)

in systemmd file

Environment=PORT=3000

and in nginx file

  location / {
     proxy_pass http://127.0.0.1:3000;
     # ........ continue with rest 
     # ........ continue with rest
  }

you can find if anything is running in port 8080 with this command

sudo netstat -peant | grep ":8080 "

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM