Haproxy SSL リダイレクト

Haproxy SSL リダイレクト

haproxy がどのように動作するかを正確に理解しているかどうかわかりません。http ベースの通信を行う数台のサーバーで構成されたシステムがあります。haproxy をロード バランサーとして、また同時に https サーバーのようなものとして使用したいと考えています。次のように動作するはずです。ユーザーがアドレスを書き込み、haproxy が決定します。http の場合は https にリダイレクトし、https の場合は http 経由でシステムに接続します。つまり、haproxy を使用するクライアントのみが https 接続を持つ必要がありますが、システムを使用する haproxy は http を持つ必要があります。説明されているアーキテクチャのイメージは次のとおりです。

ここに画像の説明を入力してください

haproxy 構成ファイルを作成しましたが、http から https にリダイレクトして最初のサイトを表示することしかできず、残りは機能しません。すべての通信は次のようになります。

クライアント --(https)--> haproxy --(https)--> システム

の代わりに

クライアント --(https)--> haproxy --(http)--> システム

haproxyで作成することは可能ですか?

以下は私の haproxy 設定ファイルです:

global
    pidfile /var/run/haproxy.pid
    log 127.0.0.1 local2 debug
    maxconn 2048
    tune.ssl.default-dh-param 2048
    ca-base /etc/ssl/certs
    crt-base /etc/ssl/private

defaults
    mode        http
    option forwardfor
    option http-server-close
    log global
    option      httplog
    option dontlognull
    option forwardfor
    option http-server-close
    option redispatch
    option tcp-smart-accept 
    option tcp-smart-connect
    timeout http-request 10s
    timeout queue 1m
    timeout connect 5s
    timeout client 2m
    timeout server 2m
    timeout http-keep-alive 10s
    timeout check 5s
    retries 3
    compression algo gzip
    compression type text/html text/html;charset=utf-8 text/plain text/css text/javascript application/x-javascript application/javascript application/ecmascript application/rss+xml application/atomsvc+xml application/atom+xml application/atom+xml;type=entry application/atom+xml;type=feed application/cmisquery+xml application/cmisallowableactions+xml application/cmisatom+xml application/cmistree+xml application/cmisacl+xml application/msword application/vnd.ms-excel application/vnd.ms-powerpoint

frontend https-in
    bind *:80
    redirect scheme https if !{ ssl_fc }
    bind *:443 ssl crt /etc/ssl/private/cert.pem
    capture request header X-Forwarded-For len 64
    capture request header User-agent len 256
    capture request header Cookie len 64
    capture request header Accept-Language len 64
    rspadd Strict-Transport-Security:\ max-age=15768000
    option contstats
    default_backend share-https

backend share-https
    option httpchk GET /share
    balance roundrobin
    cookie JSESSIONID prefix
    server main srv1:9080 cookie main check inter 5000 weight 4
    server secondary srv2:9080 cookie secondary check inter 5000 weight 1

答え1

問題は、私が説明したシステムがAlfrescoだったためでした。「share」というアプリには、httpsをブロックするCSRFPolicyがあります。これによると解決:

  1. 「CSRFPolicy」のデフォルト設定を次の場所からコピーします:

TOMCAT_HOME/webapps/share/WEB-INF/classes/alfresco/share-security-config.xml

に:

TOMCAT_HOME/shared/classes/alfresco/web-extension/share-config-custom.xml

  1. 属性 replace="true" を追加します。

<config evaluator="string-compare" condition="CSRFPolicy" replace="true">

  1. プロパティを更新するリファラーそして起源Apache VirtualHostのFQDN(https)

<referer>https://HAProxyAddress/.*</referer> <origin>https://HAProxyAddress</origin>

以上です。私にとってはうまくいきました。

関連情報