HAProxy 环境拒绝连接

HAProxy environment refusing to connect

我在带有 HAProxy 的负载均衡器后面安装了 2 个 Web 服务。虽然 3 台服务器的服务 运行 响应相当好,但只有一台服务器的其他服务没有。

所以基本上这是应该发生的事情:

loadbalancer --> rancherPlatformAdministration if certain url is used
loadbalancer --> rancherServices 用于所有其他请求

这是我的 haproxy.cfg:

#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
    log         127.0.0.1 local2

    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        haproxy
    group       haproxy
    daemon

    # turn on stats unix socket
    stats socket /var/lib/haproxy/stats

#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
defaults
    mode                    http
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    option forwardfor       except 127.0.0.0/8
    option                  redispatch
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 10s
    timeout check           10s
    maxconn                 3000

frontend http-in
    bind *:80
    # Define hosts
    acl host_rancherAdmin hdr(host) -i admin.mydomain.tech

    use_backend rancherPlatformAdministration if host_rancherAdmin
    default_backend rancherServices

backend rancherServices
    balance roundrobin
    server rancherserver91 192.168.20.91:8080 check
    server rancherserver92 192.168.20.92:8080 check
    server rancherserver93 192.168.20.93:8080 check

backend rancherPlatformAdministration
    server rancherapi01 192.168.20.20:8081 check

wget --server-response foo.mydomain.tech 以 401 回答,这是尊重的行为,因为我没有提供用户名或密码。我也可以用我的浏览器打开 foo.mydomain.tech 并登录。所以这部分就像我之前说的那样工作。

wget --server-response 192.168.20.20:8081(是的,这个 Tomcat 确实是 运行ning 在 8081 下)本地负载均衡器响应 200,因此工作正常,同时尝试 wget --server-response admin.mydomain.tech结果如下:

--2018-06-10 20:51:56--  http://admin.mydomain.tech/
Aufl"osen des Hostnamens admin.mydomain.tech (admin.mydomain.tech)... <PUBLIC IP>
Verbindungsaufbau zu admin.mydomain.tech (admin.mydomain.tech)|<PUBLIC IP>|:80 ... verbunden.
HTTP-Anforderung gesendet, auf Antwort wird gewartet ...
  HTTP/1.0 503 Service Unavailable
  Cache-Control: no-cache
  Connection: close
  Content-Type: text/html
2018-06-10 20:51:56 FEHLER 503: Service Unavailable.

我很确定我在这里遗漏了一些东西;我知道将请求转发为第 4 层或第 7 层请求的区别——这似乎工作得很好。我提供 mode http 所以我在第 7 层...

关于这里发生的事情或我如何调试它的任何提示?

事实证明,在我的例子中,selinux 是个阻碍——在 setenforce 0 将其设置为宽容模式后,它就起作用了…… 由于此更改不是重启持久的,我必须按照此处的说明进行操作:https://www.tecmint.com/disable-selinux-temporarily-permanently-in-centos-rhel-fedora/