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. 대체="true" 속성을 추가합니다.

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

  1. 속성 업데이트추천인그리고기원Apache VirtualHost의 FQDN(https) 사용

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

그리고 그게 다야. 그것은 나를 위해 작동합니다.

관련 정보