首页 > 解决方案 > 这个 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

再说一次,我不明白重点。

标签: haproxy

解决方案


在大多数 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

推荐阅读