haproxy - 这个 haproxy 声明是什么意思:不幸的是,许多管理员混淆了“以 root 身份启动”和“以 root 身份运行”
问题描述
haproxy“安全考虑”部分中有一个声明:
不幸的是,许多管理员混淆了“以root身份启动”和“以root身份运行”,导致在启动haproxy之前要进行uid更改,从而降低了有效的安全限制。 https://cbonte.github.io/haproxy-dconv/2.3/management.html#8
我不明白,当我们启动 haproxy 时,为了简单起见,让我使用 linux 默认的nobody 帐户:
we need to config it in /etc/haproxy/haproxy.cfg glboal section:
uid 99
gid 99
and then start haproxy
done
ps -lef|grep "haproxy"
5 S nobody 25613 1 0 80 0 - 6446 ep_pol 17:16 ? 00:00:00 /usr/local/sbin/haproxy -D -f /etc/haproxy/haproxy.cfg -p /var/run/haproxy.pid
we can see that nobody is the process owner
我的意思是正确的,uid 和 gid 配置应该在启动 haproxy 之前完成,为什么该声明表明这样做是错误的?
我试图理解它的含义,我得到了这个:
may be it suggest we should use root user for the config:
uid 0
gid 0
and then start haproxy,
and then change uid and gid to another user,
and then restart it
再说一次,我不明白重点。
解决方案
在大多数 UNIX 系统上,低于 1024 的端口被定义为特权端口检查这个答案https://stackoverflow.com/a/10182831/6778826
当您想绑定到端口 80/443 或低于 1024 的任何其他端口时,HAPorxy 必须以 root 身份启动。绑定完成后,将 HAProxy 切换到配置文件中定义的非特权用户。
从您的步骤来看,最后一步是不必要的。
may be it suggest we should use root user for the config:
uid 0
gid 0
and then start haproxy,
and then change uid and gid to another user,
# and then restart it <= this is not necessary
listen on privileged ports and accept requests
推荐阅读
- python - 如何为每周分析调整移动平均线?
- javascript - 仅在单击时发送到道具
- django - 带有多对多 InlineFormset ValueError 的 Django CreateView- ModelForm
- ruby-on-rails - 有没有办法在连接表中键入枚举列的强制转换值?
- winapi - 如何在 PC 上为 SHGetKnownFolderPath 获取每个用户令牌?
- unity3d - 使用 Vimeo SDK 和 AVPro Video 时 Unity 中的自适应分辨率错误
- python - AWS SES 发送批量模板电子邮件返回“模板数据无效”
- javascript - 复选框将所有选项存储到数据库中,而不是一个
- c++ - 将外部文件添加到 makefile
- python - What is the equivalent of SENTRY_USER_ATTRS in the new SDK sentry-sdk/sentry-python?