0

I want to host my own server and database on my computer, I don't want to pay monthly for services. I developed a node.js app and it's using a postgresql database. I have a domain with an angular app and the app needs to use data from the server.

Can someone tell me how I can do this and which OS would be the best?

Thanks!

Vali
  • 41
  • 4
  • Any OS. You just need to get a static IP + configure your router for public access. – vitaly-t Oct 09 '16 at 12:26
  • This is generally a really bad idea and opens your home up to all kinds of problems if you don't know what you're doing (and if you're asking this question, you probably don't). There are *free* options such as Heroku out there, pick one of those instead please. – Paul Oct 09 '16 at 13:59
  • Did [my post below](http://stackoverflow.com/questions/39941955/how-to-host-node-js-server-and-postgresql-database-from-my-computer/39944271#39944271) answer your question? If it did then you may consider [accepting the answer](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work/5235#5235) because right now other people searching for this problem see that your question has no good answer and may not read it. If it didn't answer your question then please comment on what is missing. I'm going through my old answers and want to improve them if they are not clear. Thanks – rsp Nov 10 '16 at 09:16

1 Answers1

0

You have to do few things for that to work.

  1. First, your Angular app needs to be able to connect with your home server so it either needs a static IP address accessible from the outside, a dynamic IP with dynamic DNS, or a VPN.
  2. Your server needs to properly support CORS so that your Angular app would be able to connect with it. It will send OPTIONS requests that your server needs to handle properly.
  3. Make sure that your server is always on, the internet connection is reliable, the power is reliable and that your services are properly restarted on reboot.
  4. Make sure that your server is always up to date with security patches, is configured properly and doesn't use any unneeded software and services.

For (1) you have a lot of options and it all depends on whether you have a static or dynamic IP address, whether it is accessible from the internet etc. which you didn't include in your answer.

For (2) it depends on what Node framework do you use for you server-side application which you didn't include in your question. You need to use a way to set up CORS that is specific for the framework that you use.

The (3) is hard in home environment but it's important because on any downtime your users will not be able to use your application.

The (4) is critical in home environment because if anyone breaks into your server, he'll have access to your home network which may have a different kinds of consequences that breaking into a data center.

Another option would be to use a cheap VPS provider like Digital Ocean where you can get a server for $5 a month (or 2 months for free with this link) which may be less hassle that setting up your own server - for which you have to pay for electricity, manage the hardware, monitor the connectivity etc.

If you choose a VPS then (1) us taken care for you - you get your own static IP address accessible from the world, (3) is taken care for you completely, (4) is relatively easy to do and the biggest issue is making sure that CORS works as it should - but here you can host your API on the same domain as your frontend and then you don't need to worry about CORS at all.

If you get a VPS then you can host your frontend Angular app from the same server so that it doesn't even have to cost you more.

rsp
  • 107,747
  • 29
  • 201
  • 177
  • I've tried everything in the past - cloud servers, home servers, shared hosting and dedicated hosting. In the end I came to conclusion that if you have a real product, then the best way to spend your money is a dedicated server. Just so, the biggest problem with the cloud hosting - disproportional cost increase as you opt for better hardware / throughput. Home server is a joke, you're better off with shared hosting. – vitaly-t Oct 09 '16 at 14:44