为什么HAProxy在此URL上运行curl时显示服务器的检查URL是404?

时间:2018-02-22 14:21:04

标签: haproxy

我正在设置HAProxy以在3个后端之间对资源进行负载平衡。这是HAProxy配置:(在下面的代码片段中,我用example.net替换了实际的域名)

global
  log 127.0.0.1 local2
  log-send-hostname
  maxconn 2000
  pidfile /var/run/haproxy.pid
  stats socket /var/run/haproxy.sock mode 600 level admin
  stats timeout 30s
  daemon

   # SSL ciphers
  ...

defaults
  mode    http
  option  forwardfor
  option  contstats
  option  http-server-close
  option  log-health-checks
  option  redispatch
  timeout connect  5000
  timeout client  10000
  timeout server  10000
  ...

frontend front
  bind *:443 ssl crt /usr/local/etc/haproxy/front.pem
  reqadd X-Forwarded-Proto:\ https if { ssl_fc }
  stats uri /haproxy?stats
  option httpclose
  option forwardfor
  default_backend back
  balance source

backend back
  balance roundrobin
  option httpchk GET /healthcheck HTTP/1.0
  server server1 xxx.xxx.xxx.xxx:80 check inter 5s fall 2 rise 1
  server server2 yyy.yyy.yyy.yyy:8003 check backup
  server mysite  example.net:80 check backup 

问题如下:即使前2台服务器响应正确,基于域的服务器也始终显示为404:

HAProxy stats

对我来说反直觉的是,如果我使用curl访问同一个健康检查,我会得到一个HTTP 200(就像我希望在HAProxy统计中看到的那样):

curl -I http://example.net/healthcheck
HTTP/1.1 200 OK

当我ping我的网站时,我得到:

# ping example.net
PING example.net (217.160.0.195) 56(84) bytes of data.
64 bytes from 217-160-0-195.elastic-ssl.ui-r.com (217.160.0.195): icmp_seq=1 ttl=50 time=45.7 ms

是否因为我的域的IP与其他域(1& 1共享主机)共享,HAProxy无法访问它?为什么这样以及如何使HAProxy正确到达它?

0 个答案:

没有答案