0
我们尝试配置两回在HAProxy的负载均衡方案HTTPS结束。HAProxy的与miltiple后端
我们试图终止SSL,hrd_beg,...但不能预期结果 来作为我们试图请求被转移到的,而不是默认后端到其他后端每个配置。
下面是我的配置文件。
global
log 127.0.0.1 local0 notice
log 127.0.0.1 local1 debug
maxconn 5000 # Total Max Connections. This is dependent on ulimit
daemon
quiet
nbproc 1 # Number of processing cores. Dual Dual-core Opteron is 4 cores for example.
chroot /usr/share/haproxy
user haproxy
group haproxy
#stats socket /var/run/haproxy.stat mode 600
defaults
log global
# Setting options
option dontlognull #Disable logging of null connections as these can pollute the logs
option redispatch # Enable session redistribution in case of connection failure, which is important in a HA environment
option tcp-smart-accept # Performance tweak, saving one ACK packet during the accept sequence
option tcp-smart-connect # Performance tweak, saving of one ACK packet during the connect sequence
# Setting timeouts
timeout connect 5s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 5s
retries 3
# Slowloris protection
timeout http-request 10s # Slowloris protection
timeout tarpit 1m # tarpit hold time
timeout queue 1m
backlog 10000
frontend ap_ft_https
bind *:443 ssl crt /home/mykey.pem
mode tcp
acl dcall url_sub dc
use_backend dc_bk_https if dcall
use_backend ap_bk_https if { hdr_beg(host) -i ap }
use_backend dc_bk_https if { hdr_beg(host) -i dc }
default_backend ap_bk_https
# Configuration for AP Portals
backend ap_bk_https
mode tcp
balance roundrobin # Load Balancing algorithm
reqadd X-Forwarded-Proto:\ https
#option tcplog
default-server inter 5s rise 2 fall 5
server server1 x.x.x.x:443 weight 1 maxconn 512 check
# server server2 x.x.x.x:443 weight 1 maxconn 512 check
#Configuration for DC Portals
backend dc_bk_https
mode tcp
balance roundrobin # Load Balancing algorithm
reqadd X-Forwarded-Proto:\ https
#option tcplog
default-server inter 5s rise 2 fall 5
server server1 x.x.x.x:443 weight 1 maxconn 512 check
server server2 x.x.x.x:443 weight 1 maxconn 512 check
#HAProxy Stats configuration
listen stats
mode http
bind 0.0.0.0:8880
clitimeout 100s
srvtimeout 100s
contimeout 100s
timeout queue 100s
stats enable
stats hide-version
stats refresh 30s
stats show-node
stats uri /haproxy?stats
stats realm Admin\ Portal\ HAProxy\ Statistics
stats auth admin:xxxx
我的网址开头像apxxx.domain.com和dcxxx.domain.com。
我想配置HAProxy的这样一种方式,如果请求的是apxxx.domain.com那么就应该去HAProxy的后端ap_bk_https并以同样的方式,如果它是dcxxx.domain.com它应该去HAProxy的后端dc_bk_https。
您的帮助将是赞赏!
这听起来不错,但在我们的情况下,我在这种情况下domain.com提到apxxx.domain.com和dcxxx.domain.com我们的域名是相同的两个后端是相同的区别是apxxx和dcxxx及再怎么这将在端口443上工作,在端口80上它已经工作了! – bankat
试试这个,如果有任何问题请告诉我。 前端HTTP-在 绑定*:80 ACL app_ap hdr_end(主机)-i apxxx.domain.com ACL app_dc hdr_end(主机)-i dcxxx.domain.com use_backend ap_bk_https如果app_ap use_backend dc_bk_https如果app_dc –
我已根据您的需要编辑了答案。尝试一下,并在发生任何问题时通知我。 –