Luis González Luis González - 1 year ago 166
Node.js Question

How deal with NVM in production environments?

I am using NVM to develop a Sails web application. I have installed node v0.12.7, through NVM and I use this version to run the website.

nvm use 0.12.7
sails lift

Sails uses port 1337 by default, but for production environment we change it to 443. The problem is that this port requires root privileges, and NVM is installed for just one user. So if I try sudo sails lift, I get an error saying that sails is not installed.

What is the most effective way for dealing with that issue? How can I use NVM to develop my project and deploy it?

I have thought different possible solutions but I don't know if they are good or insecure.

  1. Forwarding ports using
    . The problem with that is socket could not works beacuse a proxy.

  2. Change permissions for a port. Could be security risk if node have vulnerabilities.

  3. Install NVM with root. The problem is that I uses NVM to avoid use
    for deploy or run applications, and this will force me to do it.

What are the best practices in this context?

Thanks in advance.

Answer Source

I have solved the issue doing the following.

I have change the owner and the group of node.

which node # gives a string with the path to node
sudo chown root:root path_to_node
sudo chmod u+s path_to_node

That way, whatever user executing node will do it with the owner privileges. And in this case, the owner is root and its privileges are enough to use ports under 1024.

What do you think about this solution?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download