2016-07-26 12 views
1

私はポート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ヘッダーを設定する必要があるので、私は、追加ヘッダの例を踏襲

ようにすること hereを説明
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: */* 

答えて

関連する問題