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: */*