0

Can I use node.js to build a web server and domain from scratch, instead of using apache for a website? Can All the backend hosting and domain work be done by node.js?

Thank in advanced, I'm trying to build a site for my resumé, would like to build it from scratch, to showcase my resumé. Back to front end. ...etc

1 Answers1

0

So, sort of yes, but also sort of no. To build a back end with node you need to use a framework like express, and to serve it you'd need something like this. But to safely expose it to the open internet, you should definitely use apache or nginx to proxy requests to the port that your app is listening on. This is because it's extremely unsafe to expose your node server to the internet, and because both ports 80 and 443 require root privilege, making it even more unsafe. But if you really want to serve directly to your js backend, you can do so with something like this Best practices when running Node.js with port 80 (Ubuntu / Linode) for linux or this https://unix.stackexchange.com/questions/319734/pf-forwarding-all-packets-on-port-80-from-any-interface-to-socks-proxy for mac. This also requires root privilege to implement, and is still extremely unsafe.

marcx
  • 168
  • 1
  • 8
  • Here is a great tutorial to help you get started with a simple express backend that serves static files, so there's no need to worry about trying to learn angular or react or backbone to build your front end https://www.codementor.io/codeforgeek/build-website-from-scratch-using-expressjs-and-bootstrap-du107sby7 – marcx Jun 13 '17 at 18:12
  • Thanks, I'll do more research. – user8156006 Jun 13 '17 at 18:15
  • Modern web development is really confusing, don't get discouraged! You can definitely host from your computer, but it means you have to forward ports 80 or 443 through your router and expose your computer's ports directly to the internet. That also means you can't turn it off. It's pretty much mandatory to shell out for hosting or a server like digitalocean, but make sure that they can handle node! Some don't. The hardest thing is learning enough about architectures and terminology to be able to google your way to success. For a lot of use cases, a backend might not even be necessary. – marcx Jun 13 '17 at 18:22
  • Here's a little more info for you https://stackoverflow.com/questions/11066958/in-the-model-view-controller-principle-what-is-the-frontend-and-what-is-the-bac – marcx Jun 13 '17 at 18:22