Please be aware that this is an old post, more than one year old, so you might need to look for an updated version of this article either on this site or using your favourite search engine.
One of the things that I hate about nodejs is that I will have to run it as root if I want to use the port 80, but
yesterday while I was reviewing a book called
Mastering Web Application Development with [Express](https://www.packtpub.com/web-development/mastering-web-application-development-express)
and one of the solutions which he talked about so that you dont need to use the root user is to redirect the ports
iptable , so this is what you have to do :
sudo iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT sudo iptables -A INPUT -i eth0 -p tcp --dport 8080 -j ACCEPT sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080
remember to change eth0 to the one you are connecting to, in my vagrant it was eth1
And since iptable does not save anything as permanent, you have to do small work (read more about it here)
Install the service sudo apt-get install -y iptables-persistent Start the service sudo service iptables-persistent start Save the rules sudo iptables-save | sudo tee /etc/iptables/rules.v4 Restart the service sudo service iptables-persistent restart
And we are done, no need to use the root account any more ;)
PS: This article will work with ubuntu 16.04 , because service does not work with ubuntu 16.04 as I know, but not 100% sure.