网址:
https://www.npmjs.com/package/node-mitmproxy
命名一个proxy.js文件
内容:
module.exports = {
sslConnectInterceptor: (req, cltSocket, head) => false,
requestInterceptor: (rOptions, req, res, ssl, next) => {
console.log(
`${rOptions.method} ${rOptions.protocol}//${rOptions.hostname}:${rOptions.port}${
rOptions.path
}`
);
const port = parseInt(rOptions.port);
if (rOptions.hostname === "222.168.122.20" && port > 8080 && port < 8100) {
rOptions.hostname = "127.0.0.1";
rOptions.port = 3009;
}
next();
},
responseInterceptor: (req, res, proxyReq, proxyRes, ssl, next) => {
next();
}
};
```
mac上设置:
```
sudo npm install node-mitmproxy -g
在文件所在文件夹下:
node-mitmproxy -c proxy.js
```