I am using the MEAN Stack and I could run my frontend already. After ng build
I moved all the content in the dist
folder to var/www/html
and could access my website. I'm using Apache and my frontend is now available online. The problem is now my backend. I am using Node.js but I have no clue how I can make it "online" for everyone. With npm start server.js
or pm2 start server.js
I can make my Node.js server run and everything is working fine, but it's only working for me. When my friend accessed my website, the backend is not running (only frontend).
So my question is, how can I make my node.js server public? Is there a way to run node.js in Apache also?
Actually I made a apache proxy and even with nginx but seems not to work yet...
I followed this step from here: https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-14-04
and also from here: https://medium.com/@pierangelo1982/using-nodejs-app-with-apache-374b37c6140d
EDIT:
I am able to server my backend with nginx but I have to stop my Apache server but my apache server is serving the angular frontend...
What should I do?
EDIT2:
Thanks of the help from Gouveia, I am able to serve front and backend with NGINX
server {
listen 80;
server_name http://travelinked.vm.mi.hdm-stuttgart.de;
location / {
root /var/www/html;
}
location /api {
proxy_pass http://141.62.65.110: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;
}
}
As you can see the site is available but still the backend is not running outside of my intranet. For me the backend is loading but for you guys I think not
http://travelinked.vm.mi.hdm-stuttgart.de is the website