Haproxy SSL-Umleitung

Haproxy SSL-Umleitung

Ich bin nicht sicher, ob ich verstehe, wie Haproxy genau funktioniert. Ich habe ein System, das aus mehreren Servern besteht, deren Kommunikation auf HTTP basiert. Ich möchte Haproxy gleichzeitig als Lastenausgleich und als etwas wie einen HTTPS-Server verwenden. Das sollte folgendermaßen funktionieren: Der Benutzer schreibt die Adresse und Haproxy entscheidet – wenn es HTTP ist, wird es auf HTTPS umgeleitet, wenn es HTTPS ist, wird die Verbindung zum System über HTTP hergestellt. Ich meine, dass nur Clients mit Haproxy eine HTTPS-Verbindung haben sollten, Haproxy mit dem System jedoch HTTP haben sollte. Hier ist das Bild mit der beschriebenen Architektur:

Bildbeschreibung hier eingeben

Ich habe eine Konfigurationsdatei für Haproxy geschrieben und bekomme nur eine Umleitung von http auf https und die Anzeige der ersten Site – der Rest ist tot, weil die gesamte Kommunikation so aussieht:

Client --(https)--> HaProxy --(https)-->System

anstatt

Client --(https)--> haproxy --(http)-->System

Ist es möglich, es mit Haproxy zu erstellen?

Unten ist meine Haproxy-Konfigurationsdatei:

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

Antwort1

Das Problem war, dass das von mir beschriebene System Alfresco war - die App namens "share" hat eine CSRFPolicy, die https blockiert. DemnachLösung:

  1. Kopieren Sie die Standardkonfiguration „CSRFPolicy“ von:

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

Zu:

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

  1. Fügen Sie das Attribut replace="true" hinzu:

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

  1. Aktualisieren der EigenschaftenReferrerUndHerkunftmit FQDN (https) des Apache VirtualHost

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

Und das ist alles. Bei mir funktioniert es.

verwandte Informationen