普通用户启动服务需要绑定80和443端口,而在linux中,1024以下端口被称为privileged port,即特权端口,特权端口只能被由root启动的进程监听。
1. 权限绑定
设置特权
为特定可执行文件赋予绑定特权端口的权限(永久):
setcap 'cap_net_bind_service=+ep' /path/to/program
sudo setcap 'cap_net_bind_service=+ep' $(readlink -f $(which node))
取消特权
setcap -r /path/to/program
Now for the caveats:
- You will need at least a 2.6.24 kernel
- This won’t work if your file