0

우리는 haproxy로드 균형 조정 시나리오에서 https를 사용하여 두 개의 백 엔드를 구성하려고합니다.miltiple 백엔드가있는 haproxy

우리는 ssl termination, 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으로 시작됩니다.

내가 요청이 apxxx.domain.com위한 경우 그때는 그것이 haproxy로 이동한다 dcxxx.domain.com위한 경우 백엔드 ap_bk_https과 같은 방법으로 haproxy로 이동해야하는 방식을 haproxy 구성 할 백엔드 dc_bk_https.

귀하의 도움은 입니다.!

답변

1
/****************************************************/ 
      ROUTING BY SUB-Domain 

    frontend http-in 
      bind *:80 
      acl app_ap hdr_end(host) -i apxxx.domain.com 
      acl app_dc hdr_end(host) -i dcxxx.domain.com 

      use_backend ap_bk_https if app_ap 
      use_backend dc_bk_https if app_dc 


Now all request from apxxx.domain.com and dcxxx.domain.com will be redirected to your respected backends. 
/**********************************/ 




/*************** OLD ANSWER ************************/// 
     Basically what you want is to route by domain name. 
     Here's an example which does exactly what you want. Have a look at it. Its simple . 

     http://seanmcgary.com/posts/haproxy---route-by-domain-name 

/** OLD ANSWER ENDS ************/ 

이 문제가 해결되기를 바랍니다.

+0

우리의 경우에는 우리의 도메인 이름이 모두 백 엔드에 동일합니다.이 경우 apxxx.domain.com과 dcxxx.domain.com을 언급했는데 domain.com은 apxxx와 dcxxx의 동일한 차이점이 있습니다. 이것은 포트 443에서 작동합니다. 포트 80에서 이미 작동 중입니다! – bankat

+0

문제가있는 경우이를 시도해보고 알려주세요. 프론트 엔드 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 –

+0

나는 당신의 필요에 따라 대답을 편집했다. 그것을 시도하고 어떤 문제의 경우 알려 주시기 바랍니다. –