URL-Umleitung und TCP-Proxy in Haproxy

URL-Umleitung und TCP-Proxy in Haproxy

Auf einem Server mit nur einer IPv4 und laufendem Haproxy möchte ich zum Zweck der SSL-Passthrough-Funktion eine URL umleiten und eine andere auf TCP-Ebene als Proxy verwenden.

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 }

Für das Umleitungspräfix ist jedoch der HTTP-Modus erforderlich, und für das Proxy-Passthrough ist der TCP-Modus erforderlich.

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

Wenn ich zwei Frontends in 443 binde, treten beim Laden der Seiten Fehler auf.

Wie kann ich weiter vorgehen?

BEARBEITEN

Ich habe versucht, ein HTTP-Backend für die Umleitung zu erstellen

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 }

Aber wenn ich zu domain-for-redirect.com gehe, erhalte ich die Meldung ERR_SSL_PROTOCOL_ERROR. Wie kann ich das Zertifikat im Backend laden?

Antwort1

Sie müssen die SSL-Option mit einem gültigen oder selbst signierten SSL-Zertifikat hinzufügen: statt: bind *:443 verwenden: bind *:443 ssl crt /etc/ssl/private/certFileName.pem

verwandte Informationen