Linux 为什么 HAProxy 不会侦听端口 80?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5445652/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why HAProxy won't listen on port 80?
提问by Gubatron
Fresh machine, no http servers are running (no httpd, no lighttpd, no nginx)
新机器,没有运行 http 服务器(没有 httpd,没有 lighttpd,没有 nginx)
$ netstat -nat | grep 80 | grep LISTEN
yields nothing...
一无所获……
Here's my HAProxy conf, what can be the reason for HAProxy not to
这是我的 HAProxy conf,HAProxy 不这样做的原因是什么
global
maxconn 72000
daemon
defaults
mode http
timeout connect 4000ms
timeout client 60000ms
timeout server 30000ms
frontend my_frontend
bind *:80
default_backend cdn
backend cdn
server cdn1 10.177.0.17:80 weight 1 maxconn 8192 check
server cdn2 10.177.1.92:80 weight 1 maxconn 8192 check
server cdn3 10.177.1.147:80 weight 1 maxconn 8192 check
server cdn4 10.177.1.202:80 weight 1 maxconn 8192 check
server cdn4 10.177.1.202:80 weight 1 maxconn 8192 check
server cdn5 10.177.1.211:80 weight 1 maxconn 8192 check
server cdn6 10.177.1.93:80 weight 1 maxconn 8192 check
server cdn7 10.177.1.230:80 weight 1 maxconn 8192 check
server cdn8 10.177.0.7:80 weight 1 maxconn 8192 check
server cdn9 10.177.0.196:80 weight 1 maxconn 8192 check
server cdn10 10.177.1.82:80 weight 1 maxconn 8192 check
server cdn11 10.177.0.124:80 weight 1 maxconn 8192 check
server cdn12 10.177.1.142:80 weight 1 maxconn 8192 check
server cdn13 10.177.1.58:80 weight 1 maxconn 8192 check
server cdn14 10.177.1.137:80 weight 1 maxconn 8192 check
server cdn15 10.177.1.169:80 weight 1 maxconn 8192 check
server cdn16 10.177.0.187:80 weight 1 maxconn 8192 check
server cdn17 10.177.1.95:80 weight 1 maxconn 8192 check
server cdn18 10.177.1.123:80 weight 1 maxconn 8192 check
running haproxy-1.4.13 from source.
从源运行 haproxy-1.4.13。
When I try to start it I get this error
当我尝试启动它时出现此错误
[ALERT] 084/220004 (2409) : Starting frontend my_frontend: cannot bind socket
回答by Gubatron
So I tried starting haproxy with the root user and it worked. I'm not sure if it's a good idea to run it under root though.
所以我尝试用 root 用户启动 haproxy 并且它起作用了。不过,我不确定在 root 下运行它是否是个好主意。
回答by hilo
haproxy can run under some other user. such as nobody..
haproxy 可以在其他用户下运行。比如没人..
回答by Zimbabao
add global config parameter called user
添加名为 user 的全局配置参数
user nobody
or some less privileged user. Still you need to start as root, but after acquiring the port process itself will reduce the user/privileges to nobody.
或一些特权较低的用户。您仍然需要以 root 身份启动,但在获取端口进程本身后,用户/权限将减少到任何人。