1

我想在端口 80 上运行我的 node.js 应用程序而不以 root 身份运行它

$> which node
/usr/bin/node

我曾尝试使用 setcap 但它不起作用:

$> sudo setcap CAP_NET_BIND_SERVICE=+eip /usr/bin/node
Failed to set capabilities on file `/usr/bin/node' (Operation not 
permitted)
The value of the capability argument is not permitted for a file. Or 
the file is not a regular (non-symlink) file

我究竟做错了什么 ?

4

2 回答 2

0

最后,我使用了端口重定向,不是使用 iptables 而是使用 ufw

https://serverfault.com/questions/238563/can-i-use-ufw-to-setup-a-port-forward

于 2018-06-11T14:54:46.413 回答
0

低于 1000 的端口需要 sudo 权限。您可以使用以下命令允许它在不使用 sudo 的情况下绑定到端口 80:

sudo setcap 'cap_net_bind_service=+ep' `which node`
于 2021-06-09T09:41:20.103 回答