mirror of
https://github.com/fatedier/frp.git
synced 2026-05-15 16:15:49 -06:00
[GH-ISSUE #1493] frp的frps.service配置的User=nobody绑定不了某些端口 #1179
Labels
No labels
In Progress
WIP
WaitingForInfo
bug
doc
duplicate
easy
enhancement
future
help wanted
invalid
lifecycle/stale
need-issue-template
need-usage-help
no plan
proposal
pull-request
question
todo
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/frp#1179
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ju0594 on GitHub (Nov 2, 2019).
Original GitHub issue: https://github.com/fatedier/frp/issues/1493
Issue is only used for submiting bug report and documents typo. If there are same issues or answers can be found in documents, we will close it directly.
(为了节约时间,提高处理问题的效率,不按照格式填写的 issue 将会直接关闭。)
(请不要在 issue 评论中出现无意义的 加1,我也是 等内容,将会被直接删除。)
(由于个人精力有限,和系统环境,网络环境等相关的求助问题请转至其他论坛或社交平台。)
Use the commands below to provide key information from your environment:
You do NOT have to include this information if this is a FEATURE REQUEST
What version of frp are you using (./frpc -v or ./frps -v)?
0.29.0
What operating system and processor architecture are you using (
go env)?Configures you used:
Steps to reproduce the issue:
1.复制frps.service到/etc/systemd/system
2.在/etc/frp/frps.ini 填写比如 vhost_https_port = 443
3.使用
systemctl start frps启动 发现启动失败Describe the results you received:
使用
systemctl status frps -l显示Describe the results you expected:
Additional information you deem important (e.g. issue happens only occasionally):
Can you point out what caused this issue (optional)
使用User=nobody的时候,只能绑定一些高位端口,443之类的端口都不能绑定,
netstat -ntulp |grep 443发现并没有被别的软件占用。但是把User=nobody注释掉使用root用户就没问题了,很奇怪,不知道为啥。
@deadlineOvO commented on GitHub (Nov 2, 2019):
正常现象
@xqzr commented on GitHub (Nov 2, 2019):
这是系统限制
@ysc3839 commented on GitHub (Nov 2, 2019):
许多 Unix 系统会限制只有 root 用户才能绑定一些端口。而且这种限制很可能是写死的,也就是说没办法设置“允许某用户组绑定端口”。这种情况下只能先以 root 用户启动,绑定端口后再用 setuid 来 “drop root”。
@fatedier commented on GitHub (Nov 2, 2019):
你可以认为这只是一个示例配置,可以根据自己的需要进行修改。
@Xeath commented on GitHub (Nov 3, 2019):
……
部分系统限制了非 root 账户不能绑定 1024 以下的端口。
@deadlineOvO commented on GitHub (Nov 5, 2019):
额外一提:假设不使用 root 来进行绑定 1024 一下端口的话,可以使用 setcap 或者是增加 systemd 单元文件的 cap 相关选项来达成目的
@deadlineOvO commented on GitHub (Nov 5, 2019):
详细看了下,使用 systemd 的发行版可以使用
CapabilityBoundingSet =来设置这个服务的一些能力@iBug commented on GitHub (Nov 17, 2019):
这里有点错误,
CapabilityBoundingSet是限制该服务拥有的 cap,也就是不在这个列表里的 cap 都会被去掉。要想添加一个 cap,正确的做法是这样你的 frps 就可以绑定 1~1023 这些端口 (Privileged Ports) 了
@deadlineOvO commented on GitHub (Nov 17, 2019):
是这个样子的啊
@LHANDRH commented on GitHub (Dec 6, 2019):
放在 [Service] 段下。
我粘个完整的方便后面的人看:
@deadlineOvO commented on GitHub (Dec 6, 2019):
不过那个 5s 究竟是为了什么?
@deadlineOvO commented on GitHub (Dec 7, 2019):
看了下 文档 ,事实上使用
CapabilityBoundingSet也可以增加 cap ,不过CapabilityBoundingSet也可以做到删减 cap@668168 commented on GitHub (Dec 14, 2020):
特意登陆表示感谢。
首先您提供了root cause的关键解法。
我还在困惑这句应该放在哪里生效,
AmbientCapabilities=CAP_NET_BIND_SERVICE
您又贴了完整code。
希望我这个无用的感谢信息没有给大家造成困扰。
@buptzyf commented on GitHub (Sep 24, 2021):
树莓派 ubuntu16 下,以非root用户登录,未解决问题
更新
成功了,解决问题了
ExecStart=/usr/bin/frps -c /etc/frp/frps.ini,这里frpc的路径不能放在某个用户目录下,比如 /home/user3/frpc/