2017-11-16 21 views
1

URL에 특정 키워드가 일치하면 SSL 포트가 아닌 (8080)으로 가고 나머지 호출은 SSL 포트 8443으로 이동해야 SSL 용 Haproxy를 구성해야합니다.SSL에 대한 Haproxy acl 규칙

URL example.com이 브라우저에 입력되고 내 컴퓨터의 localhost를 가리키는 경우 example.com에 127.0.0.1을 할당했습니다.

프론트 엔드 SSL에서 'reporting'또는 'account_management'작업의 URL이 백엔드 proxybackend를 나타내지 않으므로 acl 규칙이 원하는대로 작동하지 않습니다. action = reporting이있는 URL이 있더라도 default_backend SSLappAPI를 통과하는 모든 트래픽.

SSL 트래픽 용으로 SSL이 아닌 포트를 사용하려고하거나 아래의 haproxy 구성에서 문제가 발생하여 acl이 작동하지 않습니다. https://example.com/api/?uid=NrpB1vfSR01KVsxw1YI5H4&action=reporting

frontend main *:80 

    acl is_api url_param(action) -i host_check 
    use_backend appAPI  if is_api 
    default_backend    appUI 
    option    forwardfor 

frontend ssl 
    mode tcp 
    bind *:443 
    option tcplog 
    acl server_ssl urlp_sub(action) -i reporting 
    acl server_ssl urlp_sub(action) -i account_management 
    acl server_ssl hdr(host) -i example.com 
    acl server_ssl hdr_sub(host) -i example.com 

    use_backend proxybackend if server_ssl 
    default_backend    SSLappAPI 
    option    forwardfor 

backend appUI 
    server  ui-server 127.0.0.1:8080 check maxconn 50#ui <- leave this format to allow for selective script replacement 

backend appAPI 
    server api-server 127.0.0.1:8080 check maxconn 750#api <- leave this format to allow for selective script replacement 
    timeout http-keep-alive 0s 

backend SSLappAPI 
    mode tcp 
    server api-server 127.0.0.1:8443 check maxconn 800#ssl <- leave this format to allow for selective script replacement 

backend proxybackend 
    server proxyserver 127.0.0.1:8080 

답변

0

규칙 'req_ssl_sni'속임수를 썼는지 :

어떤 도움이 많이

예 URL을 이해할 수있을 것이다. SSL에 대해 정상적인 ACL이 작동하지 않는 것처럼 보입니다. 여기 req_ssl_sni가 구조를 위해 올 것입니다.

같은 haproxy를 사용하는 2 개의 SSL 서버에 대한 작업 코드는 다음과 같습니다. 또한 아래 코드는 SSL 인증서에도 사용할 수 있으며 haproxy 서버에서 .PEM 인증서를 함께 설치할 필요가 없습니다.

프론트 엔드 SSL 모드의 TCP SSL 바인드 * : 443 옵션

tcp-request inspect-delay 5s 
tcp-request content accept if { req_ssl_hello_type 1 } 

use_backend SSLappAPI if { req_ssl_sni -i anoexample.com } 
use_backend proxybackend if { req_ssl_sni -i example.com } 

default_backend    SSLappAPI 

backend SSLappAPI 
mode tcp 
server api-server 127.0.0.1:8443 check maxconn 800#ssl <- leave this format to allow for selective script replacement 

backend proxybackend 
mode tcp 
#option nolinger 
option tcplog 
balance roundrobin 
hash-type consistent 
option srvtcpka 

# maximum SSL session ID length is 32 bytes. 
stick-table type binary len 32 size 30k expire 30m 

# make sure we cover type 1 (fallback) 
acl clienthello req_ssl_hello_type 1 
acl serverhello rep_ssl_hello_type 2 

# use tcp content accepts to detects ssl client and server hello. 
tcp-request inspect-delay 5s 
tcp-request content accept if clienthello 

# no timeout on response inspect delay by default. 
tcp-response content accept if serverhello 

# SSL session ID (SSLID) may be present on a client or server hello. 
# Its length is coded on 1 byte at offset 43 and its value starts 
# at offset 44. 
# Match and learn on request if client hello. 
stick on payload_lv(43,1) if clienthello 

# Learn on response if server hello. 
stick store-response payload_lv(43,1) if serverhello 

#option ssl-hello-chk 

server proxyserver 127.0.0.2:443 
tcplog