遇见的困难&解决办法
- 当request更改请求域名时,请求接口报错"Changing the Host server for HTTP/2 connections not allowed: (pre-gapp.inuozhen.com,80)"
解决:参照https://discourse.mitmproxy.org/t/reverse-mode-change-request-host-according-to-the-sni-https/466 遇见类似的问题解决方案,建议关掉HTTP 2,因为mitmproxy没有对此做兼容。
再对照开源文档options.py
self.add_option(
"http2", bool, True,
"Enable/disable HTTP/2 support. "
"HTTP/2 support is enabled by default.",
)
发现在options里面增加(“http2”, bool, False,"")应该能关掉HTTP 2
改动mit.py:
def start():
myaddon = AddHeader()
opts = options.Options(listen_port=8090)
opts.add_option("http2", bool, False,"")
pconf = proxy.config.ProxyConfig(opts)
m = DumpMaster(opts)
m.server = proxy.server.ProxyServer(pconf)
m.addons.add(myaddon)
然后运行成功,成功代理到预发
- js如果轮询时间太短,比如1s,那么在vue表格下拉的时候会出现短暂的卡顿
- 如果要部署到ECS集群,如何保存网络一致
- 如果针对不同客户端自动分发不同代理
- js如何将request请求转化成CUrl,从而被复制,因为用python的curlify库最后请求都是格式不正确,需要js下载另一个库去解析
解决:既然知道了curl格式,就通过js直接模拟
curlify(request_detail) {
const headers = { ...request_detail.request_headers };
const acceptEncoding =
headers["Accept-Encoding"] || headers["accept-encoding"];
// escape reserve character in url
const url = request_detail.url;
const curlified = ["curl", `'${url}'`];
if (request_detail.method.toUpperCase() !== "GET") {
curlified.push("-X", request_detail.method);
}
Object.keys(headers).forEach((key) => {
curlified.push("-H", `'${key}: ${headers[key]}'`);
});
if (request_detail.body) {
curlified.push("-d", `'${request_detail.body}'`);
}
if (/deflate|gzip/.test(acceptEncoding)) {
curlified.push("--compressed");
}
return curlified.join(" ");
}