alibaba / anyproxy Goto Github PK
View Code? Open in Web Editor NEWA fully configurable http/https proxy in NodeJS
Home Page: http://anyproxy.io
License: Apache License 2.0
A fully configurable http/https proxy in NodeJS
Home Page: http://anyproxy.io
License: Apache License 2.0
Caught exception: TypeError: Object # has no method 'access'
at Recorder.self.getBody (/Users/xxxx/node_modules/anyproxy/lib/recorder.js:112:12)
at /Users/xxxx/node_modules/anyproxy/lib/recorder.js:134:18
at callback (/Users/xxxx/node_modules/anyproxy/node_modules/nedb/lib/executor.js:30:17)
at Cursor.execFn (/Users/xxxx/node_modules/anyproxy/node_modules/nedb/lib/datastore.js:417:12)
at Cursor._exec (/Users/xxxx/node_modules/anyproxy/node_modules/nedb/lib/cursor.js:172:17)
at /Users/xxxx/node_modules/anyproxy/node_modules/nedb/lib/executor.js:40:13
at Object.q.process as _onImmediate
at processImmediate as _immediateCallback
AnyProxy is about to exit with code: 0
如题,虽然我知道目前是透明代理,但是效率真的很高啊,其他的都太低
建议增加auth认证,任意形式
或者增加自定义头,不满足则不代理,防止被扫,也增加调试的机密性
GG思密达
what do you guys think about a separate module for the web frontend and the backend
1、anyproxy作为代理服务器,捕获手机app发送的请求。
2、anyproxy异常退出,之后重启anyproxy服务器。
3、手机app在不退出重启的情况下,继续发送请求。此时,anyproxy丢失某些手机发送的请求。(此时anyproxy只能捕获部分手机发送的数据包)。
【关键】:异常退出之后重启anyproxy,丢失手机端的数据请求。
目前的certGenerator.js是預設把cert.serialNumber都設為'01'
https://github.com/alibaba/anyproxy/blob/master/lib/certGenerator.js#L14
但是根據ssl的原設計, cert.serialNumber在同一個root CA內是不應該重複的.
目前已知只有Firefox會抱怨 serial重複的問題.
我的patch根據產生證出所使用的CN的MD5直給予每張cert獨立的serial
應該能夠有效解決這個問題. 我的fork已經改了太多東西, 不大方便直接做pull request所以麻煩你直接看一下我的diff吧...
Cojad@b4fc7af
增强对windows的支持
支持指定ca证书路径
anyproxy --throttle 0.1
throttle :0.1kb/s
/usr/local/lib/node_modules/anyproxy/node_modules/stream-throttle/src/throttle.js:54
throw new Error('throttle rate must be a positive number');
^
Error: throttle rate must be a positive number
at new ThrottleGroup (/usr/local/lib/node_modules/anyproxy/node_modules/stream-throttle/src/throttle.js:54:15)
at new proxyServer (/usr/local/lib/node_modules/anyproxy/proxy.js:85:28)
at Object. (/usr/local/lib/node_modules/anyproxy/bin.js:86:5)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
at startup (node.js:140:18)
at node.js:1001:3
Hi,
Great module, awesome work :). I have been using this for my projects, with selenium webdriver (proxying to anyproxy). One thing, I realized is that things are really really slow. It takes ages to load websites.
Any idea why its so slow, or my implementations wrong. I am using NPM module for anyproxy and webdriverIO to setup browser + proxy.
Thank you!
Caught exception: RangeError: Invalid array buffer length
at new ArrayBuffer (native)
at new Uint8Array (native)
at allocate (buffer.js:98:17)
at new Buffer (buffer.js:49:12)
at Function.Buffer.concat (buffer.js:234:16)
at /usr/lib/node_modules/anyproxy/lib/requestHandler.js:178:52
at /usr/lib/node_modules/anyproxy/node_modules/async/lib/async.js:607:21
at /usr/lib/node_modules/anyproxy/node_modules/async/lib/async.js:246:17
at iterate (/usr/lib/node_modules/anyproxy/node_modules/async/lib/async.js:146:13)
at async.eachSeries (/usr/lib/node_modules/anyproxy/node_modules/async/lib/async.js:162:9)
AnyProxy is about to exit with code: 0
filter 的时候出现这个错误,根本不能过滤
服务器被设置为在80端口监听https请求,anyproxy会自动把80端口改为443,导致请求超时。
RT,google没找到,nodjs版本5.x和0.12
可以来个sample么?
为了方便rule文件的编写,anyproxy长期在GLOBAL.util下注入了很多的三方模块,比如iconv-lite mysql等,并作为optionalDependencies依赖写在了package.json
但随着用户需求的不断变化,由anyproxy来控制这些组件显然是不合适的,而且大量的依赖已经影响到了安装的速度。树莓派用户表示根本就编译不动这么多东西....
anyproxy 3.0以后的版本中,将会挪走这些依赖。如果使用者仍希望在rule里面快速引用各种模块,不妨参考这份文档,把模块安装到必要的路径中:http://nodejs.org/api/modules.html#modules_loading_from_node_modules_folders
Hi, @ottomao anyproxy目前只支持存储request的内容到文件中(希望我的理解是正确的),能否增加个可选项,支持可以存储某次请求的request和response的body内容&Header内容到文件中呢?因为有时候仅看打印出来的结果是不够的,可能还会写些脚本来分析一次请求,所以提出了这个提议:-)您看下实现这个功能ok么
Many thanks~
我的是Mac电脑,安装了 Virtualbox,启动anyproxy的时候获取了virtualbox的ip而不是本机的ip,导致无法使用。
ifconfig:
vboxnet0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500 ether 0a:00:27:00:00:00 inet 192.168.56.1 netmask 0xffffff00 broadcast 192.168.56.255 en4: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 options=4<VLAN_MTU> ether 00:0e:c6:c3:c7:69 inet6 fe80::20e:c6ff:fec3:c769%en4 prefixlen 64 scopeid 0xb inet 192.168.6.105 netmask 0xffffff00 broadcast 192.168.6.255
anyproxy:
GUI interface started at : http://192.168.56.1:8002/ Http proxy started at 192.168.56.1:8001
其中 192.168.6.105
才是正确的ip
错误信息如下,求解答
Fetch API cannot load http://127.0.0.1:8001/api/app/5715e829a14a74d2227b98f6. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
是这样,我们希望代理之后,增加注入的功能(比如注入weinre)
但发现某些站点页面注入失败,初步判断是服务器要支持chunked编码输出
res.on('data',function(chunk){
//未触发data事件
userRes.write(chunk);
});
res.on('end',function(){
userRes.write("something"); //某些站点页面注入失败
userRes.end();
});
It seems that anyproxy installation is failed on win8.1
Here is some log from a user's report
6870 error [email protected] install: node-gyp rebuild
6870 error Exit status 1
6871 error Failed at the [email protected] install script.
Hello,I can't run it by the command "anyproxy",so I went to the anyproxy folder run it by "nohup nodejs bin.js&" , It works OK and so fast at the beginning. But the memory(1G) used too fast.At last anyproxy existed automatically. I think there is something wrong... please help me. it's so good.
只停掉了httpServer,webServer和wsServer都没停掉。
我想让所有访问foo.com的请求转向访问指定的ip,但是hostname不变。
在fiddler中可以用下面的设置
···
oSession.bypassGateway = true;
oSession["x-overrideHost"] = x.x.x.x;
我的意思 服务器端 是 有多个IP的 客户端指定 100.100.100.1 这个代理IP,那么服务器端就会用100.100.100.1去获取内容,同理100.2那么获取时也是用100.2 ,
现的情况是,我有多个IP,但是虽然我客户端指定了不同的IP代理地址,但是始终获取内容时都是通过100.1去获取了
1、anyproxy作为代理服务器,捕获手机app发送的请求。
2、anyproxy异常退出,之后重启anyproxy服务器。
3、手机app在不退出重启的情况下,继续发送请求。此时,anyproxy丢失某些手机发送的请求。(此时anyproxy只能捕获部分手机发送的数据包)。
【关键】:异常退出之后重启anyproxy,丢失手机端的数据请求。
非常好的一个项目~mark下了谢谢
Hi, I've been playing around with any proxy, everything works, but I cant get https proxy interception to work, I've installed openssl properly for windows. But everytime I run the command anyproxy --root I get errors saying "openssl is not recognized as an internal or external command" . I'm not sure what i'm doing wrong, can anyone please help me with this.. Thanks
I also see the directory 'cert', how can i use these certificates, ??? Thanks
应该如何加入用户验证功能?
在苹果手机里的无线设置中,手动设置了wifi的http代理为anyproxy的代理服务器地址,能正常上网,但发现一个问题:可以浏览appstore里的应用,但不能下载,把代理去掉就可以下载了,能否修复这个问题?
在规则配置中增加一栏颜色选项
已经生成证书,客户端也安装 ,已经信任。
anyproxy --intercept
重新启动之后,并没有达到明文解析https的作用。反而导致了https的请求失败。
不知道,这个是要怎么用?
My system needs another proxy server to access internet, does anyproxy allow to set it?
如題, 主要是https遇到的問題, 希望某些https某些網域可以直接pass through..不要動到fake CA.
而且這樣比較不會因為奇形怪狀的https封包導致anyproxy crash
I wrote a simple script in accordance with the instructions.
But the script start error in idea.
blow is my code:
var proxy = require("anyproxy");
//create cert when you want to use https features
//please manually trust this rootCA when it is the first time you run it
//!proxy.isRootCAFileExists() && proxy.generateRootCA();
var options = {
type : "http",
port : 8088,
hostname : "localhost",
rule : require("./rule.js")
};
new proxy.proxyServer(options);
blow is the console output:
"D:\JetBrains\IntelliJ IDEA 14.1.4\bin\runnerw.exe" "C:\Program Files\nodejs\node.exe" proxy2.js
===========
failed to create cert dir ,please create one by yourself - \Users\QiuQiu\.anyproxy_certs\
this error will not block main thread unless you use https-related features in anyproxy
===========
this is a blank rule for AnyProxy
Anyproxy rules initialize finished, have fun!
path.js:8
throw new TypeError('Path must be a string. Received ' +
^
TypeError: Path must be a string. Received null
at assertPath (path.js:8:11)
at Object.win32.join (path.js:221:5)
at Object.module.exports.generateCacheDir (e:\idea_workspace\web-port\node_modules\anyproxy\lib\util.js:49:26)
at new Recorder (e:\idea_workspace\web-port\node_modules\anyproxy\lib\recorder.js:16:31)
at e:\idea_workspace\web-port\node_modules\anyproxy\proxy.js:100:43
at ChildProcess.exithandler (child_process.js:194:7)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at maybeClose (internal/child_process.js:818:16)
at Socket.<anonymous> (internal/child_process.js:319:11)
Process finished with exit code 1
It seems that Node.js has changed the SNICallback interface in v0.10 and v0.12. Users of Anyproxy in Node v0.10 may suffer some error when calling SNICallback.
Ref: https://github.com/joyent/node/wiki/API-changes-between-v0.10-and-v0.12
使用了 --intercept --rule ./env_testing_api.js
,
rule 文件为:
/*
read the following wiki before using rule file
https://github.com/alibaba/anyproxy/wiki/What-is-rule-file-and-how-to-write-one
*/
module.exports = {
summary:function(){
return "reverse proxy - assign an IP adress for some request";
},
shouldInterceptHttpsReq :function(req){
//intercept https://github.com/
//otherwise, all the https traffic will not go through this proxy
// return true;
if(req.headers.host == "api.mydomain.com"){
return true;
}else{
return false;
}
},
replaceRequestOption : function(req,option){
var newOption = option;
//options : http://nodejs.org/api/http.html#http_http_request_options_callback
if(newOption.headers.host == "api.mydomain.com"){
newOption.hostname = "123.57.189.194";
}
return newOption;
}
};
Default:
var T_TYPE_HTTP = 0,
T_TYPE_HTTPS = 1,
DEFAULT_PORT = 8001,
DEFAULT_WEB_PORT = 8002,
DEFAULT_WEBSOCKET_PORT = 8003,
DEFAULT_CONFIG_PORT = 8088,
DEFAULT_HOST = "localhost",
DEFAULT_TYPE = T_TYPE_HTTP;
✓ node bin.js -r reverse_proxy.js
rule file loaded :/opt/anyproxy/reverse_proxy.js
reverse proxy - assign an IP adress for some request
Anyproxy rules initialize finished, have fun!
GUI interface started at : http://66.35.69.94:8002/
Http proxy started at 66.35.69.94:8001
OK, but my app uses nodejs and socketio serving on port 49114 host 127.0.0.1, my reverse_proxy.js :
module.exports = {
summary:function(){
return "reverse proxy to localhost:49114";
},
replaceRequestOption : function(req,option){
var newOption = option;
newOption.hostname = "127.0.0.1";
newOption.port = "49114";
return newOption;
}
};
My chrome:
XHR finished loading: GET "http://myhost.myname.com:8001/socket.io/1/?t=1424747292746".
socket.io.js:2371 WebSocket connection to 'ws://myhost.myname.com:8001/socket.io/1/websocket/anJVrPujLK3N8VuxcUgV' failed: Connection closed before receiving a handshake response
socket.io.js:3012 XHR finished loading: GET "http://myhost.myname.com:8001/socket.io/1/xhr-polling/anJVrPujLK3N8VuxcUgV?t=1424747304818".
socket.io.js:3012 XHR finished loading: GET "http://myhost.myname.com:8001/socket.io/1/xhr-polling/anJVrPujLK3N8VuxcUgV?t=1424747305107".
socket.io.js:3012 XHR finished loading: GET "http://myhost.myname.com:8001/socket.io/1/xhr-polling/anJVrPujLK3N8VuxcUgV?t=1424747305390".
socket.io.js:2625 XHR finished loading: POST "http://myhost.myname.com:8001/socket.io/1/xhr-polling/anJVrPujLK3N8VuxcUgV?t=1424747305389".
socket.io.js:3012 XHR finished loading: GET "http://myhost.myname.com:8001/socket.io/1/xhr-polling/anJVrPujLK3N8VuxcUgV?t=1424747305510".
socket.io.js:3012 XHR finished loading: GET "http://myhost.myname.com:8001/socket.io/1/xhr-polling/anJVrPujLK3N8VuxcUgV?t=1424747325800".
socket.io.js:3012 GET http://myhost.myname.com:8001/socket.io/1/xhr-polling/anJVrPujLK3N8VuxcUgV?t=1424747346094 net
Socket io fails from websocket to post
My node stdout:
received request to : myhost.myname.com:8001/
==>will forward to real server by proxy
received request to : myhost.myname.com:8001/socket.io/socket.io.js
==>will forward to real server by proxy
received request to : myhost.myname.com:8001/socket.io/1/?t=1424747671286
==>will forward to real server by proxy
received request to : myhost.myname.com:8001/favicon.ico
==>will forward to real server by proxy
received request to : myhost.myname.com:8001/socket.io/1/xhr-polling/u8iayXvF0VxGXZArcUgW?t=1424747681681
==>will forward to real server by proxy
I could reconfig nodejs app to connect to socketio on port 8003 but this is not necessary with haproxy:
frontend l
bind 1.2.3.4:8001
mode http
default_backend L
backend L
mode http
balance roundrobin
server static 127.0.0.1:49114 check inter 2000
AliBaba Can you help me use your cool app like this?
Rick
在手机上设置anyproxy代理之后,无法访问网络。并且电脑端的anyproxy查看不到任何移动端的数据记录。
I don't think that currently SNI is supported.
In some cases, we want to ignore the warning about unsecure certificates. Here we should add a config for that.
很诡异的问题,通过代理之后,有编码错乱的问题。没挂代理是正常的
anyproxy在下载大文件时是先下载到服务器,再转发给客户端浏览器是吗?现在在使用anyproxy下载大文件的时候客户端浏览器会出现一直等待的情况。可以通过某种方法实时转发文件内容吗?
默认不启用rule_sample/rule_allow_CORS
I'm using anyproxy as module, rule_default.js looks like always loaded even if I specific my user rule.
Which modify the headers below.
在我把anyproxy當成module來使用時, 我發現到rule_default.js似乎不管我有沒有使用我自己的rule都會被載入, 造成所有的CORS header都會被改變成下面的樣子.
access-control-allow-origin : -___-||
access-control-allow-headers : -___-||
access-control-allow-methods : GET, POST, PUT
access-control-allow-credentials : true
I have to trace into mergeCORSHeader function in rule_default.js to comment out those lines. However, I'm looking for much more elegant way to do it.
我必須自己到rule_default.js內把mergeCORSHeader函式內的那幾行給註解掉. 總之, 我希望未來有比較好的方式可以關掉預設的CORS header規則.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.