明確 HTTP Proxy 樣式

最後更新: 2026-11-03 12:15:20 +0800 +0800
tags: Http | Proxy | TLS
原文以英文撰寫。您正在閱讀AI翻譯版本。

Proxy 比較 #

Proxy 行為 ↓ / 用戶端 → Proxy 跳接 →HTTP 至 ProxyHTTPS 至 Proxy
轉送 Proxy — 用戶端傳送絕對形式的請求,例如 GET http://target/path優點: 最簡單且廣泛支援;Proxy 可以驗證、快取、篩選、路由與記錄 HTTP 請求;協定負荷低。 缺點: 用戶端至 Proxy 的請求、標頭、URL 與本文都是純文字,除非目標承載資料另有保護;在不受信任的本機網路上不安全。優點: 加密用戶端至 Proxy 的跳接,將 Proxy 認證資訊與 HTTP 請求詳細資料隱藏於本機網路;TLS 在 Proxy 終止後,Proxy 仍保留 HTTP 感知能力。 缺點: TLS 設定與 CPU 成本較高;Proxy 仍可看見並修改請求內容;比 HTTP Proxy URL 更不普遍部署或設定。
通道 Proxy — 用戶端傳送 CONNECT host:port,然後串流位元組優點: 透過 Proxy 連到 HTTPS 原始站的標準且廣泛相容方式;端對端 TLS 仍位於用戶端與目的地之間;Proxy 通常無法檢查 HTTP 承載內容。 缺點: 用戶端至 Proxy 跳接上的 CONNECT 請求與目的地主機/連接埠為純文字;Proxy 流量可被觀察,且可能遭封鎖或限制;若沒有 TLS 攔截,就沒有 HTTP 快取或請求層級政策。優點: 加密 CONNECT 設定(包括 Proxy 認證與目的地授權)以及通道跳接;通道內使用 HTTPS 時,可在不受信任的本機網路上提供分層保護。 缺點: 兩層 TLS 與額外設定負荷;較難偵錯且相容性稍低;Proxy 解密外層 TLS 後仍可觀察連線中繼資料,而政策大多仍限於連線層級。

「HTTPS 至 Proxy」表示 Proxy 本身透過 TLS 存取,例如 https://proxy.example:443 的 Proxy 設定。這與目標網站是否使用 HTTPS 無關。

HTTP 轉錄範例 #

http
# Forward proxy over HTTP: these HTTP bytes are visible on the client-to-proxy hop.
Client -> proxy
GET http://origin.example/reports/42 HTTP/1.1
Host: origin.example
Proxy-Authorization: Basic <credentials>

Proxy -> client
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 11

{"ok":true}
http
# Forward proxy over HTTPS: the wire carries TLS records to proxy.example.
# After TLS decryption at the proxy, the HTTP exchange is:
Client -> proxy
GET http://origin.example/reports/42 HTTP/1.1
Host: origin.example
Proxy-Authorization: Basic <credentials>

Proxy -> client
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 11

{"ok":true}
http
# Tunnel proxy over HTTP: CONNECT headers are visible on the client-to-proxy hop.
Client -> proxy
CONNECT origin.example:443 HTTP/1.1
Host: origin.example:443
Proxy-Authorization: Basic <credentials>

Proxy -> client
HTTP/1.1 200 Connection Established

# Subsequent bytes are an end-to-end TLS session with origin.example;
# the origin HTTP requests are not exposed to the proxy.
http
# Tunnel proxy over HTTPS: the wire carries outer TLS records to proxy.example.
# After outer TLS decryption at the proxy, the HTTP exchange is:
Client -> proxy
CONNECT origin.example:443 HTTP/1.1
Host: origin.example:443
Proxy-Authorization: Basic <credentials>

Proxy -> client
HTTP/1.1 200 Connection Established

# Subsequent bytes carry an inner TLS session with origin.example inside the
# outer TLS connection; origin HTTP requests remain encrypted from the proxy
# and end-to-end to origin.example.

評論

在 GitHub 上閱讀或評論(發表評論需要登入)