Using authbind with Node.js

DEPRECATED: This post may no longer be relevant or contain industry best-practices.

After recommending a method for dropping root privileges in a previous post, the community gave a bunch of recommendations for alternative methods of doing the same thing. Several people mentioned authbind, which is a simple utility for running apps and giving them permissions to listen to the privileged ports (below 1024).

Here are some commands you can run to get authbind up and running on your Debian based server. I'm sure that if you have a different distro, you probably only need to change the installation line.

# Install authbind in Debian/Ubuntu
sudo apt-get install authbind

# Configure authbind
sudo touch /etc/authbind/byport/80
sudo chown user /etc/authbind/byport/80
sudo chmod 755 /etc/authbind/byport/80

# Run simple node app
authbind node server.js

# Run node app with forever
authbind --deep forever server.js
Tags: #nodejs #linux
Thomas Hunter II Avatar

Thomas has contributed to dozens of enterprise Node.js services and has worked for a company dedicated to securing Node.js. He has spoken at several conferences on Node.js and JavaScript, published a book on microservices, and is an organizer of Nodeschool SF.