私はポート8181
でローカルにhttpサーバーを実行しています。私のデバイスにmitmproxy
が設定されているので、特定のドメインから自分のローカルサーバーインスタンスに要求を転送する必要があります。だから私は、サンプルスクリプトをリダイレクト要求を使用していhereの説明:これは動作しますmitmproxy localhostにリクエストをリダイレクトし、ホストヘッダーを設定します。
def request(flow):
# pretty_host takes the "Host" header of the request into account,
# which is useful in transparent mode where we usually only have the IP
# otherwise.
# Method 2: Redirect the request to a different server
if flow.request.pretty_host.endswith("mydomain.com"):
flow.request.headers["Host"] = flow.request.headers
flow.request.host = "localhost"
flow.request.port = 8181
flow.request.scheme = 'http'
が、私は元の要求ホストにHost
ヘッダーを設定する必要があるので、私は、追加ヘッダの例を踏襲
flow.request.headers["Host"] = flow.request.headers
ですが、mitmproxy
の場合、リクエストにこのヘッダーセットが表示されず、localhost
サーバーログに表示されません。
だから私は
* Trying ::1...
* Connected to localhost (::1) port 8181 (#0)
> GET /something HTTP/1.1
> Host:mydomain.com
> User-Agent: curl/7.43.0
> Accept: */*