This is basically a complement to the answer from maerics, but since I want to add some sample code, I am writing another answer with additional information on how to prevent security problems.
Typically, web servers run as root, as this is necessary to bind to ports below 1024, but then they change the user they run to a non-privileged user.
You can do this with node.js using process.setuid("username")
.
In the following example, the server starts, and then the root permissions of the user "www-data" are deleted after binding to port 80 when starting as root:
function StartServer() { console.log("Starting server...");
Bastian
source share