-
-
Notifications
You must be signed in to change notification settings - Fork 1
NginX and Node
After installing ubuntu somewhere, I use the VPS of ovh.com (ubuntu 18.04 french actually)
Connect to your VPS
Then install nginx (no need to update on ovh it's all uptodate)
root@vps726492:~# apt install nginx
You can connect to your site via its IP adress
Check if it works It works too
Install nodejs and npm
root@vps726492:~# sudo apt install nodejs
root@vps726492:~# sudo apt install npm
Next steps is to create an application
Install the correspondant node packages here it's expressjs (should look at the correspondant wiki page)
Now we just need to make the right redirrections with a domain name to localhost:3000
so I have bought a domain name called ethical-hacking-resources.com
root@vps726492:/# sudo vim /etc/nginx/sites-available/ethical-hacking-resources
So here is what contain the file
upstream ethical-hacking-resources.com {
server localhost:3000;
}
server {
listen 80;
listen [::]:80;
server_name ethical-hacking-resources.com;
location / {
proxy_pass http://ethical-hacking-resources.com;
}
}
We enable the site
root@vps726492:/# sudo ln -s /etc/nginx/sites-available/ethical-hacking-resources /etc/nginx/sites-enabled/ethical-hacking-resources
test if the nginx config is okey
root@vps726492:/# sudo nginx -t
Will say everything is okey
at this time if you do sudo service nginx reload the domaine name will point to a 500 error so we need to run the app
#sudo service nginx reload
so going to the folder where the app is located and
#node app.js
now the app must be run with forever or pm2 so we choose pm2
#sudo npm install pm2 -g
now you just need to run
#pm2 start app.js
and your done YEY
what you see is that I have just cloned an app in the folder you just have seen otherwise it will be in the same name as the creator to be clean in work