HAProxy环境拒绝连接

时间:2018-06-10 19:12:15

标签: haproxy

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

所以基本上应该发生什么:

loadbalancer - >如果使用某个URL,则为rancherPlatformAdministration 负载均衡器 - > 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真的在8081以下运行)本地从loadbalancer以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层......

有关此处发生的事情或我如何调试此事的任何提示?

1 个答案:

答案 0 :(得分:0)

事实证明,在我的情况下,selinux是showstopper - 在setenforce 0将其置于宽松模式后,它才起作用...... 由于此更改不是重新启动持久性的,因此我必须按照此处的说明进行操作:https://www.tecmint.com/disable-selinux-temporarily-permanently-in-centos-rhel-fedora/