问题
I installed a HAPROXY for balance between two servers. Unfortunately the HAPROXY return random ERR_EMPTY_RESPONSE. I installed the stats also but the stats does not appear frequently because sometimes the stats is shown. I double check with some friends my configuration and I did not found problems.
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
My configuration:
- HA Proxy version 1.6.3 (package 1.6.3-1ubuntu0.1 amd64)
- Ubuntu 16.04.2 LTS
- Cloud Machine on AWS LightSail 512KB RAM
- System with all packages updated.
I already read the answer of similar question at HAProxy random HTTP 503 errors and the answer is not the same. As suggested there the command netstat -tulpn | grep 80
does not show two HAPROXY running:
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN -
But ps ax | grep haproxy
returns:
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
回答1:
Well, I dig more into HAProxy and read a lot of tutorials and I believe I found the solution.
I did two changes:
- Changed
hdr_end(host)
tohdr_dom(host)
- Added
mode http
to:frontend http_in
,backend srv_audio
andbackend srv_stats
Now, HAPROXY is very stable without bizarre behavior
来源:https://stackoverflow.com/questions/43016507/haproxy-random-empty-response