1
我在端口8181
本地運行一個HTTP服務器。我在我的設備上配置了我的mitmproxy
,現在我需要將來自特定域的請求轉發到本地服務器實例。所以我使用請求重定向示例腳本描述here:mitmproxy重定向請求本地主機和設置主機標頭
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: */*