主要参考官方文档
http://anyproxy.io/cn/
module.exports = { // 模块介绍 summary: 'my customized rule for AnyProxy', // 发送请求前拦截处理 *beforeSendRequest(requestDetail) { /* ... */ }, // 发送响应前处理 *beforeSendResponse(requestDetail, responseDetail) { /* ... */ }, // 是否处理https请求 *beforeDealHttpsRequest(requestDetail) { /* ... */ }, // 请求出错的事件 *onError(requestDetail, error) { /* ... */ }, // https连接服务器出错 *onConnectError(requestDetail, error) { /* ... */ } };
跟fiddler 比起来。虽然fiddler 也是可以通过custom rule 进行修改,但是它用的是js net 的语法,有点挫。anyproxy用的是node.js 。很方便使用mysql之类。可以根据url匹配进行修改。
anyproxy 运行很容易挂,推荐使用 pm2 进行运行。
pm2 start anyproxy --name anyproxy1 -x -- -i -p 8001 -w 8002 -r /usr/local/lib/node_modules/anyproxy/lib/rule_default.js
挂了会自动启动
4750