2

I am able to connect to my Nodejs API server through aws by entering url such as ip + :3000. Now I do not want to show port no 3000 after url. is there any way to hide this or this will be there compulsory?

Mrugesh
  • 4,381
  • 8
  • 42
  • 84
  • See http://stackoverflow.com/questions/16573668/best-practices-when-running-node-js-with-port-80-ubuntu-linode for a few different ways of getting Node to work with port 80 (HTTP default port). – Graham Apr 06 '17 at 08:21

1 Answers1

3

You can't do this on the client side. You need to do one of:

  1. Have your nodejs server running on port 80/443
  2. Run a webserver (apache,nginx) on your nodejs server as a reverse proxy
  3. Use a load balancer.
Daniel Scott
  • 7,418
  • 5
  • 39
  • 58
  • I am using express framework. Can I use nginx instead of apache? – Mrugesh Apr 06 '17 at 08:28
  • Yep, or just run the express framework on your desired port – Daniel Scott Apr 06 '17 at 08:33
  • yes,right now I am running express on port no 3000.Should I change the port number? – Mrugesh Apr 06 '17 at 08:36
  • Up to you - it might be better to run your webserver on the 'privileged' port (<1024) and then proxy to your node server on 3000, or just run the node server on the desired port. Up to you really, depending on your use case. If this is an important service which might need to provide other features in the future then I'd probably go for the reverse proxy, if you're just testing things out or it's just a simple single service then I'd run it directly. – Daniel Scott Apr 06 '17 at 08:39