haproxy의 URL 리디렉션 및 TCP 프록시

haproxy의 URL 리디렉션 및 TCP 프록시

ipv4가 하나만 있고 haproxy를 실행하는 서버에서 SSL 통과 목적으로 URL을 리디렉션하고 TCP 수준에서 다른 프록시를 프록시하고 싶습니다.

frontend https-frontend
  bind *:443
  mode tcp
  option tcplog
  tcp-request inspect-delay 5s
  tcp-request content accept if { req_ssl_hello_type 1 }
  use_backend proxy-backend if { req.ssl_sni -i proxied-url.com }
  redirect prefix https://url-rewrited.com code 301 if  { req.ssl_sni -i domain-for-redirect.com }

그러나 리디렉션 접두사에는 http 모드가 필요하고 프록시 통과에는 tcp 모드가 필요합니다.

[WARNING] 347/153600 (1324) : config : 'redirect' rules ignored for frontend 'https-frontend' as they require HTTP mode.

443에서 두 개의 프런트엔드 바인딩을 사용하면 페이지를 로드할 때 오류가 발생합니다.

어떻게 진행하나요?

편집하다

리디렉션을 위해 http 백엔드를 시도했습니다.

frontend https-frontend
  bind *:443
  mode tcp
  option tcplog
  tcp-request inspect-delay 5s
  tcp-request content accept if { req_ssl_hello_type 1 }
  use_backend proxy-backend if { req.ssl_sni -i proxied-url.com }
  use_backend redirect-backend if  { req.ssl_sni -i domain-for-redirect.com }

backend redirect-backend
  mode http
  option ssl-hello-chk
  redirect prefix https://url-rewrited.com code 301 if { req.ssl_sni -i domain-for-redirect.com }

하지만 domain-for-redirect.com으로 이동하면 ERR_SSL_PROTOCOL_ERROR가 발생합니다. 백엔드에 인증서를 어떻게 로드할 수 있나요?

답변1

유효하거나 자체 서명된 SSL 인증서를 사용하여 SSL 옵션을 추가해야 합니다. 대신: 바인딩 *:443 사용: 바인딩 *:443 ssl crt /etc/ssl/private/certFileName.pem

관련 정보