我安装了 HAPROXY 以实现两台服务器之间的平衡。不幸的是,HAPROXY 返回随机 ERR_EMPTY_RESPONSE。我也安装了统计信息,但统计信息没有出现频繁地因为有时会显示统计数据。我和一些朋友仔细检查了我的配置,没有发现问题。
defaults
timeout connect 3000ms
timeout server 10000ms
timeout client 10000ms
global
log 127.0.0.1 local0 notice
maxconn 2000
user haproxy
group haproxy
frontend stats
bind *:1936
mode http
stats enable
stats hide-version
stats realm Haproxy\ Statistics
stats uri /
stats auth user:password
frontend http_in
bind *:80
acl is_audio hdr_end(host) -i subdomain.myserver.com
acl is_proxystats hdr_end(host) -i stats.myserver.com
use_backend srv_audio if is_audio
use_backend srv_stats if is_proxystats
# acl url_blog path_beg /blog
# use_backend blog_back if url_blog
default_backend srv_audio
backend srv_audio
balance roundrobin
server audio1 10.10.10.1:80 check
server audio2 10.10.10.2:80 check
backend srv_stats
server Local 127.0.0.1:1936
我的配置:
- HA 代理版本 1.6.3(软件包 1.6.3-1ubuntu0.1 amd64)
- Ubuntu 16.04.2 LTS
- AWS LightSail 上的云机 512KB RAM
- 所有软件包均已更新的系统。
我已经阅读了类似问题的答案HAProxy 随机 HTTP 503 错误 https://stackoverflow.com/questions/13994629/haproxy-random-http-503-errors而答案并不相同。正如建议的那样,命令netstat -tulpn | grep 80
不显示两个 HAPROXY 正在运行:
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN -
But ps ax | grep haproxy
返回:
22890 ? Ss 0:00 /usr/sbin/haproxy-systemd-wrapper -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid
22891 ? S 0:00 /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds
22894 ? Ss 0:31 /usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds
好吧,我深入研究了 HAProxy 并阅读了很多教程,我相信我找到了解决方案。
我做了两处改变:
- Changed
hdr_end(host)
to hdr_dom(host)
- Added
mode http
to: frontend http_in
, backend srv_audio
and backend srv_stats
现在,HAPROXY 非常稳定,没有奇怪的行为
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)