具有1个公共IP上的2个域的HA代理

时间:2019-03-20 11:10:06

标签: ssl proxy reverse-proxy haproxy pfsense

我正在尝试设置ha-proxy以将2个不同的域解析为2个不同的服务器,但是出于任何原因,只有第一个定义的ha-proxy后端中的第一个服务器可以正常工作。目前,ha-proxy可以正确解析Server1,但是当我尝试连接到Server2时,会在某处进行https重定向。 Https在任何Apache上均未激活。我在两个Apache服务器上都禁用了SSL-Site(a2dissite ssl ....)和SSL-mod(a2dismod ssl),但是在ha-proxy的默认配置中可以找到它。当我切换后端服务器IP时,我能够连接到Server2,但不能连接到Server1。然后将Server1重定向到https。

所以-PFSense直接在防火墙本身上提供ha-proxy软件包。那是我的第一次尝试,但遇到了我刚才描述的相同问题。因此,今天早上,我设置了一个独立的ha-proxy,但此安装遇到了同样的问题。 PFsense上的HA代理当前已关闭。 PFSense是否有可能由于我们在用于CARP接口的同一NIC上使用IP别名而无法正确重定向?

DNS

Server1.mydomain.de -> A-Record -> 62.x.x.174
Server2.mydomain.de -> A-Record -> 62.x.x.174 

设置: 具有静态WAN IP的2个PFSense网关。 PFSense配置有同步功能-因此我们拥有一个主服务器和一个备用服务器。

我们在PFSense WAN IP上使用1个虚拟IP(CARP)。

PFSense 1 WAN 62.x.x.171
PFSense 2 WAN 62.x.x.172 (currently turned off for testing)
CARP WAN 62.x.x.170
IP Alias 62.x.x.174 (on PFsense 1 WAN Interface)

由于我们已经在CARP接口的80和443上使用NAT,因此IP别名用于将NAT + Proxy重定向到DMZ中的ha-proxy。

DMZ is 192.168.10.x
ha proxy 192.168.10.20
Server 1 192.168.10.21 - Apache 2.4 listening on Port 81
Server 2 192.168.10.22 - Apache 2.4 listening on Port 82

使用ip:port连接到两台服务器都可以通过LAN进行。

所有防火墙均配置为默认允许传出。

防火墙@ ha-proxy

     To                         Action      From
     --                         ------      ----
[ 1] 80/tcp                     ALLOW IN    Anywhere
[ 2] 443/tcp                    ALLOW IN    Anywhere
[ 3] 1463/tcp                   ALLOW IN    Anywhere

防火墙@server 1

     To                         Action      From
     --                         ------      ----
[ 1] 1463/tcp                   ALLOW IN    Anywhere
[ 2] 80/tcp                     ALLOW IN    Anywhere
[ 3] 443/tcp                    ALLOW IN    Anywhere
[ 4] 81/tcp                     ALLOW IN    Anywhere

防火墙@server 2

     To                         Action      From
     --                         ------      ----
[ 1] 1463/tcp                   ALLOW IN    Anywhere
[ 2] 80/tcp                     ALLOW IN    Anywhere
[ 3] 443/tcp                    ALLOW IN    Anywhere
[ 4] 82/tcp                     ALLOW IN    Anywhere

ha-proxy配置

global
    log /dev/log    local0
    log /dev/log    local1 notice
    chroot /var/lib/haproxy
    stats socket /run/haproxy/admin.sock mode 660 level admin
    stats timeout 30s
    user haproxy
    group haproxy
    daemon

    # Default SSL material locations
    ca-base /etc/ssl/certs
    crt-base /etc/ssl/private

# Default ciphers to use on SSL-enabled listening sockets.
    # For more information, see ciphers(1SSL). This list is from:
    #  https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
    # An alternative list with additional directives can be obtained from
    #  https://mozilla.github.io/server-side-tls/ssl-config-generator/?    server=haproxy
    ssl-default-bind-ciphers     ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AE    S:!aNULL:!MD5:!DSS
    ssl-default-bind-options no-sslv3

defaults
    log     global
    mode    http
    option  httplog
    option  dontlognull
    option forwardfor
    option http-server-close
    timeout connect 5000
    timeout client  50000
    timeout server  50000
    errorfile 400 /etc/haproxy/errors/400.http
    errorfile 403 /etc/haproxy/errors/403.http
    errorfile 408 /etc/haproxy/errors/408.http
    errorfile 500 /etc/haproxy/errors/500.http
    errorfile 502 /etc/haproxy/errors/502.http
    errorfile 503 /etc/haproxy/errors/503.http
    errorfile 504 /etc/haproxy/errors/504.http

frontend http_in
    mode tcp
    bind *:80

    acl web1 hdr(host) -i server1.mydomain.de
    acl web2 hdr(host) -i server2.mydomain.de

    use_backend web1 if web1
    use_backend web2 if web2

backend web1
    option forwardfor
    server web1 192.168.10.21:81

backend web2
    option forwardfor
    server web2 192.168.10.22:82

0 个答案:

没有答案
相关问题