I would like to run node with a low privileges user, is it possible? I need to use the framework Express.js
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes. There are many solutions available to do this, depending on your exact needs.
If you want to run node on port 80, you can use nginx (doesn’t work with WebSockets yet) or haproxy. But perhaps the quickest and dirtiest is to use iptables to redirect port 80 to the port of your choice:
When you’re happy, then save the config and make sure iptables comes on at boot
To automatically start your nodejs service as non-root, and restart it if it fails, you can utilize upstart with a script like this:
If you’re on an Amazon EC2 installation, or you get an error that says
sudo: sorry, you must have a tty to run sudo, then you can replace your exec command with this:And, you didn’t ask this question, but to keep it running forever, check out monit! Here is a useful guide to setting up node.js with upstart and monit.