HTTP CONNECT Method

Die HTTP-Methode CONNECT etabliert einen bidirektionalen TCP-Tunnel durch einen Proxy-Server. Sie wird primär für HTTPS-Verbindungen durch HTTP-Proxies verwendet, wobei der Proxy nach erfolgreicher Verbindung 200 Connection Established zurückgibt.

Typ

HTTP-Methode

Syntax

CONNECT-Request verwendet Host:Port als Request-Target statt URL-Pfad.

http
CONNECT example.com:443 HTTP/1.1
Host: example.com:443

Direktiven

Die Direktiven definieren Tunnel-Target und Proxy-Verhalten.

host:port
Ziel-Host und Port für TCP-Tunnel, meist Port 443 für HTTPS oder 80 für HTTP.
Host-Header
Pflicht-Header mit identischem Wert wie Request-Target für HTTP/1.1 Konformität.
Proxy-Authorization
Optional, für Proxy-Authentication falls Proxy Credentials erfordert.

Beispiele

Nachfolgend finden Sie praktische Anwendungsbeispiele für die CONNECT-Methode.

Beispiel 1 HTTPS durch HTTP Proxy

http
CONNECT www.example.com:443 HTTP/1.1
Host: www.example.com:443

HTTP/1.1 200 Connection Established

[Client sendet TLS ClientHello]
[Server antwortet mit TLS ServerHello]
[Verschlüsselte HTTPS-Kommunikation folgt]

Browser etabliert HTTPS-Verbindung durch Corporate HTTP-Proxy via TCP-Tunnel.

Beispiel 2 Proxy Authentication Required

http
CONNECT api.example.com:443 HTTP/1.1
Host: api.example.com:443

HTTP/1.1 407 Proxy Authentication Required
Proxy-Authenticate: Basic realm="Corporate Proxy"

CONNECT api.example.com:443 HTTP/1.1
Host: api.example.com:443
Proxy-Authorization: Basic dXNlcjpwYXNz

HTTP/1.1 200 Connection Established

Proxy fordert Authentication, Client sendet Credentials, Tunnel wird etabliert.

Beispiel 3 WebSocket durch Proxy

http
CONNECT ws.example.com:443 HTTP/1.1
Host: ws.example.com:443

HTTP/1.1 200 Connection Established

GET /chat HTTP/1.1
Host: ws.example.com
Upgrade: websocket
Connection: Upgrade

HTTP/1.1 101 Switching Protocols

WebSocket-Verbindung wird durch CONNECT-Tunnel etabliert, dann Upgrade zu WebSocket.

CONNECT Tunnel Flow

CONNECT TCP-Tunnel-Ablauf

Vorteile für die Systemarchitektur

  • HTTPS durch HTTP-Proxies: Ermöglicht verschlüsselte Verbindungen durch Corporate Proxies ohne TLS-Inspection
  • Protocol-Agnostic: Tunnel transportiert beliebige Protokolle (HTTPS, WebSocket, SSH) transparent
  • End-to-End Encryption: Proxy sieht nur verschlüsselte Bytes, keine Plaintext-Inhalte

Spezifikation

RFC 9110, Section 9.3.6 – HTTP Semantics https://www.rfc-editor.org/rfc/rfc9110.html#name-connect

Weitere Spezifikationen

Proxy-Authenticate Header, Host Header