2017-11-16 12 views
1

特定のキーワードがURLに一致する場合はSSL以外のポート(8080)に、残りのコールはSSLポート8443に送信するように、SSL用にHaproxyを設定する必要があります。SSLのHaproxy aclの規則

URL example.comがブラウザに入力されていて、それが自分のマシンのlocalhostを指していると、example.comに対して127.0.0.1を割り当てました。

Frontend 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 バインド*:

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 443 オプション
関連する問題