HAProxy를 통해 SSL 트래픽 및 인증 인증서 전달

HAProxy를 통해 SSL 트래픽 및 인증 인증서 전달

클라이언트로부터 다음을 사용하여 성공적으로 POST할 수 있는 nginx가 있습니다.

curl -v --cacert ca.crt --cert client.crt --key client.key -POST https://nginx:8443/api/ -H 'Content-Type: application/json' -H 'cache-control: no-cache' [email protected]

이제 nginx 앞에 haproxy를 설치했고 동일한 방식으로 POST를 수행하려고 시도했지만 실패했습니다.

curl -v --cacert ca.crt --cert client.crt --key client.key -POST http://haproxy:8443/api/ -H 'Content-Type: application/json' -H 'cache-control: no-cache' [email protected]

오류:

 <center>The plain HTTP request was sent to HTTPS port</center>
 <hr><center>nginx</center>

내 haproxy 구성은 다음과 같습니다.

global
  log         127.0.0.1 local2
  chroot      /var/lib/haproxy
  pidfile     /var/run/haproxy.pid
  maxconn     4000
  user        haproxy
  group       haproxy
  daemon
  stats socket /var/lib/haproxy/stats

defaults
  mode                    tcp
  log                     global
  option                  tcplog
  option                  dontlognull
  option http-server-close
  option forwardfor       except 127.0.0.0/8
  option                  redispatch
  retries                 3
  timeout http-request    10s
  timeout queue           1m
  timeout connect         10s
  timeout client          1m
  timeout server          1m
  timeout http-keep-alive 10s
  timeout check           10s
  maxconn                 3000

frontend  main *:8443
  acl url_static       path_beg       -i /static /images /javascript /stylesheets
  acl url_static       path_end       -i .jpg .gif .png .css .js
  use_backend static          if url_static
  default_backend             app

backend static
  balance     roundrobin
  server      static 127.0.0.1:8443 

backend app
  mode       tcp
  balance     roundrobin
  server  nginx nginx01:8443            

HAProxy를 통해 SSL 트래픽을 전달하고 인증용 인증서를 nginx에 전달하고 싶습니다. 두 개의 LB를 갖는 것이 의미가 없다는 것을 알고 있지만 nginx와 뒤에 있는 API 서버를 수정할 수는 없지만 클라이언트는 내부에 있습니다. 이 시점에서 볼 수 있듯이 nginx에 연결할 수 있지만 haproxy는 요청의 인증서와 키를 nginx 백엔드로 전달하지 않습니다. 뭔가 빠졌나요? 이것이 내가 성취할 수 있는 일인가?

ps: 백엔드에서 'ssl verify none'을 설정하면 '필요한 SSL 인증서가 전송되지 않았습니다'라는 메시지가 나타납니다. 백엔드에서 'send-proxy'를 설정하면 nginx에서 '400 Bad Request'를 받습니다.

답변1

haproxy에 SSL 구성을 추가하고 nginx로 전달될 일부 헤더를 설정해야 합니다.

# your other config from above
 
backend app
  mode       tcp
  balance     roundrobin
  server  nginx nginx01:8443 ssl ca-file <The ca from nginx backend>

답변2

구현된 솔루션은 SS/TLS 통과를 사용하는 것이었습니다.https://www.haproxy.com/documentation/haproxy/deployment-guides/tls-infrastructure/ 프런트엔드와 백엔드를 모두 tcp 모드로 설정하면 인증서를 통과하고 nginx의 유효성을 검사하고 인증할 수 있었습니다.

관련 정보