My node.js applications I have listening on port 80 for http and 443 for https, which I believed was fairly standard practice.
However a number of examples I have re
The first line of the first article you linked to mentions the reason.
Standard practices say no non-root process gets to talk to
the Internet on a port less than 1024.
For node to bind to port 80
or 443
, you would need to run it as root, which is not a good idea.
The method you use to reroute traffic to the higher ports is up to you. The iptables
is the least resource-intensive and simplest. Another method would be to use NginX/Apache to proxy to Node. I'd say the main benefit of that method is that you can then also serve things like static files from there, and not have to serve them through Node.
Apache and NginX are both designed explicitly to be very good at serving static files, so they are extremely good at it, whereas Node is a whole JS environment, with all the overhead that involved. Node is great at handing lots of simultaneous connections, and it can certainly serve files perfectly well for normal loads, but it will use more resources than NginX to do it.
Using an HTTP-aware proxy like Apache/NginX also means that you can very easily set up multiple instances of Node to run different subdomains, or even different paths on the same domain.