2016-07-26 6 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: */* 

답변

관련 문제