its the first time i use Jelastic and i need to deploy a vuejs app from git.
I've make a Nodejs env and deploy my vuejs app. Then, i run:
cd ROOT
npm install
npm run build
And i get an successfully message: Build complete. The dist directory is ready to be deployed.
So, what i usually do next in localhost is something like this:
cd dist
npm http-server
But in Jelastic i don't really know whats next after the build. I've try to go into http://node-env.route/dist but i get a 502 error page (The opened link forwards to the environment where the application server is down or is not picked up yet.)
Hope you can help me, thank you!
In order to run your application I suggest you to install pm2 on your server and run this command:
pm2 start npm --name "your-app-alias" -- start
After re-build you need to restart:
pm2 restart your-app-alias
Maybe after that you need a reverse proxy with NGINX to link your nodejs env to your localhost. Something like that:
server {
listen 80; # the port nginx is listening on
server_name YOUR-JELASTIC-ENV-URL; # setup your domain here
location / {
expires $expires;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 1m;
proxy_connect_timeout 1m;
proxy_pass http://127.0.0.1:3000; # set the adress of the Node.js instance here
}
}
Related
I have a boring problem that I can't solve..
I tried in all ways but I don't understand why if I call the application through the IP:3000 it loads updated files, but if I try to call it trough https://domainname.ext it doesn't want to serve new files.
I tried to delete node_modules and rebuild it (npm install); to run "npm run eject" and rebuild the app; pm2 kill and restart; reboot the server but nothing...
The App is configured to run with Nginx as reverse proxy over https.
Classically one of the following solutions:
Browser cache ("external" Domains are cached, IPs not). Try a different Browser
Actually 2 apps running. Try to kill the process and see if it really goes down
Nginx caching?
Finally 😌
in my server block of nginx configuration i just changed from localhost to IP addr
location / {
proxy_pass http://IP.ADDR:3000/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
Phusion passenger does not start the node app.
For error detection and to exclude my own node app errors, I have therefore used the demo app of phusionpassenger.com and the implementation description of the passenger library:
- I implement it on our own server / Infrastacture Ubuntu 16.04 LTS server (Xenial)
- we use Nginx integration mode
- For test purposes I use the open source version of Passenger
Here is an extraction of my custom generated Nginx Server block configuration file - all other integrations of the example app should be the same:
Server {
# Tell Nginx and Passenger where the public directory of your app is
root / var / www / demo / code / public;
index index.html index.htm index.nginx-debian.html;
Server name it-vergabe.de www.it-vergabe.de;
# Turn on the passenger
Passenger_Activated on;
# Tell the passenger that your app is a Node.js app
Passenger_env_var NODE_ENV development;
Passenger_startup_file app.js;
Passenger_app_type node;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://localhost:3000/;
proxy_ssl_session_reuse off;
proxy_set_header Host $http_host;
proxy_cache_bypass $http_upgrade;
proxy_redirect off;
}
}
Error detection: I restart Nginx and get the typical 502 Bad Gateway error if the node application is not running. Now I start the node app in a separate terminal window:
demo # Ubuntu1604srv: /var/www/demo/code $ node app
The website now works flawlessly and error free.
I have now checked the Passenger Status with the Passenger Config application and found nothing that shows that the passenger has started and under his control the node application.
Does anyone know why that is? It makes no sense to use passenger and start the node app separately ...
Thank you - Greetings from Germany!
I have docker image that consist of nginx to server my index.html file with the following config:
server {
listen 80;
server_name mysite;
root /var/www/application;
index index.html;
}
No I need to add nodejs to handle /api/ location just like the following:
upstream api_node_js {
server 127.0.0.1:3000;
}
server {
listen 80;
server_name mysite;
root /var/www/application;
index index.html;
}
location /api {
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;
rewrite ^/api/?(.*) /$1 break;
proxy_pass http://api_node_js;
proxy_redirect off;
}
So I need to install and run NodeJS server on 3000 to handle api requests. My question is how should I run it correctly?
I've already tried add running via forever with the following command in my Dockerfile:
WORKDIR /var/www/application
CMD ["forever", "start", "server.js"]
But unfortunately after starting of container it immediately exited now with no errors.
Please help me what I'm doing wrong?
While #ilyapt is right, and you should separate the nginx and node into two containers, this is not the answer to your question. What you should do is omit the start from your docker cmd, to prevent forever from running in the background - causing the container to exit.
Try changing your last line in the dockerfile to this - CMD ["forever", "server.js"] and see if it helps.
Really way to correctly run is run nginx and node.js in separated containers. Docker is a platform to isolate applications from one another and it run one application in foreground and control only this application.
Start more one applications in one container is possible but this is bad idea.
So here's my setup:
Digital Ocean 1gig droplet
Ubuntu 14.04x64
Dokku 1-click installer
MongoDB attached to Dokku via https://github.com/jeffutter/dokku-mongodb-plugin. Verified. I can connect to it via robomongo
domain registered in DNS records in my DigitalOcean dashboard (subdomain.mydomain.com)
website is accessible (verified via tailed app-access.log)
the basic meanjs app via their yo generator
only modified connection to mongodb server in Dokku.
push to Dokku is successful, no push errors
DigitalOcean swapfile create (1gig), no memory warnings according to dokku logs app
properly set Dokku env variables verified via dokku config app
properly set VHOST file to mydomain.com
My issue is everytime I visit the site, assets load (up until favicon.ico, along with /lib/bootstrap/dist/css/bootstrap.min.css and many others from that directory), but it stops there. The site doesn't load anything after that. The favicon shows up then nothing.
I checked the nginx logs, nothing. This is a practice website so I will be posting the nginx.conf:
server {
listen [::]:80;
listen 80;
server_name mean.ygamretuta.xyz ;
access_log /var/log/nginx/mean-access.log;
error_log /var/log/nginx/mean-error.log;
location / {
proxy_pass http://mean;
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-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Request-Start $msec;
}
include /home/dokku/mean/nginx.conf.d/*.conf;
}
upstream mean {
server 172.17.0.62:3000;
}
I checked nginx logs, dokku logs, I got nothing. What could be wrong?
A little more googling and I found that I should issue a grunt build before I push my code to Dokku residing in Digital Ocean.
here's the discussion in meanjs issues:
https://github.com/meanjs/mean/issues/64
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
Have you tried using meteor-up ? It handles the bundling and upstart config for you.
The suggested nginx config for meteor-up is below, it looks pretty similar to yours (taken from 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;
}
}