I am trying to get a node.js site live on port 80 (I am using Digital Ocean). I doing this using systemd with in service file
...
ExecStart=/usr/bin/nodejs /var/www/bin/app.js
...
On localhost this works fine on port 80 if I use sudo to start the site, but not without sudo. Apparently you need to run as root for ports below 1024.
How do I allow sudo in the ExecStart? Or am I going completely the wrong way here and if so, how do I get the express app on port 80?
Cheers, Mike
Systemd starts the executable stated in ExecStart=
as root by default.
However, if you have specified User=
or Group=
in your service file overriding that default, and still need to run an executable that requires sudo
, prepend the command with the absolute path to your sudo
location:
...
ExecStart=/usr/bin/sudo /usr/bin/nodejs /var/www/bin/app.js
...
Systemd starts the executable stated in ExecStart=
as root by default. This means if you haven't specified User= or Group=
in our service file, your binary is started privileged.
You can verify this by starting id, or whoami program. Ex: ExecStart=/usr/bin/id
or ExecStart=/usr/bin/whoami
(note the path for the programs might be different for you)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With