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: #linux #nodejs
Thomas Hunter II Avatar

Thomas is the author of Advanced Microservices and is a prolific public speaker with a passion for reducing complex problems into simple language and diagrams. His career includes working at Fortune 50's in the Midwest, co-founding a successful startup, and everything in between.