GithubHelp home page GithubHelp logo

alibaba / anyproxy Goto Github PK

View Code? Open in Web Editor NEW
7.8K 7.8K 1.2K 4.33 MB

A fully configurable http/https proxy in NodeJS

Home Page: http://anyproxy.io

License: Apache License 2.0

JavaScript 85.95% HTML 4.54% CSS 9.40% Shell 0.12%

anyproxy's Introduction

anyproxy's People

Contributors

codingfishman avatar dickeylth avatar guox191 avatar here-we-goal avatar jiangxiang89 avatar nestoralonso avatar ottomao avatar shadyzoz avatar silentcloud avatar supnate avatar txchen avatar wuchangming avatar zhuangya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

anyproxy's Issues

如何写反向代理规则?

我想让所有访问foo.com的请求转向访问指定的ip,但是hostname不变。
在fiddler中可以用下面的设置
···
oSession.bypassGateway = true;
oSession["x-overrideHost"] = x.x.x.x;

解決Firefox抱怨sec_error_reused_issuer_and_serial的問題

目前的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

a way to disable default CORS header modification? 有沒有更好關掉預設CORS header的方法?

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規則.

Show image preview

If the response is an image, the content of response body will show as (image)

image

Can we just show the image preview instead of display (image)? Just like the Chrome Dev Tool:

image

AnyProxy 3.8.0 is about to exit with code: 0

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

userRes.write("xxxx") 在部分代理的页面无法注入

是这样,我们希望代理之后,增加注入的功能(比如注入weinre)
但发现某些站点页面注入失败,初步判断是服务器要支持chunked编码输出

res.on('data',function(chunk){
     //未触发data事件
     userRes.write(chunk);
});
res.on('end',function(){
    userRes.write("something"); //某些站点页面注入失败
    userRes.end();
});  

throttle不支持小数?

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

一个至关重要的问题,支不支持多IP出口

我的意思 服务器端 是 有多个IP的 客户端指定 100.100.100.1 这个代理IP,那么服务器端就会用100.100.100.1去获取内容,同理100.2那么获取时也是用100.2 ,
现的情况是,我有多个IP,但是虽然我客户端指定了不同的IP代理地址,但是始终获取内容时都是通过100.1去获取了

after a while, anyproxy crashed

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

Seems really slow.

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!

能否增加支持存储一次请求的request response的body和Header的内容到文件中

Hi, @ottomao anyproxy目前只支持存储request的内容到文件中(希望我的理解是正确的),能否增加个可选项,支持可以存储某次请求的request和response的body内容&Header内容到文件中呢?因为有时候仅看打印出来的结果是不够的,可能还会写些脚本来分析一次请求,所以提出了这个提议:-)您看下实现这个功能ok么

Many thanks~

import anyproxy as a module but the script start error

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

websocket needs to serve on seperate port from http?

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做手机代理服务器丢包

1、anyproxy作为代理服务器,捕获手机app发送的请求。
2、anyproxy异常退出,之后重启anyproxy服务器。
3、手机app在不退出重启的情况下,继续发送请求。此时,anyproxy丢失某些手机发送的请求。(此时anyproxy只能捕获部分手机发送的数据包)。
【关键】:异常退出之后重启anyproxy,丢失手机端的数据请求。

Anyproxy exist

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.

anyproxy做手机代理服务器丢包

1、anyproxy作为代理服务器,捕获手机app发送的请求。
2、anyproxy异常退出,之后重启anyproxy服务器。
3、手机app在不退出重启的情况下,继续发送请求。此时,anyproxy丢失某些手机发送的请求。(此时anyproxy只能捕获部分手机发送的数据包)。
【关键】:异常退出之后重启anyproxy,丢失手机端的数据请求。

用 fetch 请求时错误

错误信息如下,求解答

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.

明文解析HTTPS没有起作用

已经生成证书,客户端也安装 ,已经信任。
anyproxy --intercept
重新启动之后,并没有达到明文解析https的作用。反而导致了https的请求失败。

不知道,这个是要怎么用?

获取了错误的IP导致无法使用

我的是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

移除optional依赖的模块

为了方便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

HTTPS Proxy Interception/OpenSSL is not working.. Please Help!

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

关于anyproxy在下载体积较大的文件时的问题

anyproxy在下载大文件时是先下载到服务器,再转发给客户端浏览器是吗?现在在使用anyproxy下载大文件的时候客户端浏览器会出现一直等待的情况。可以通过某种方法实时转发文件内容吗?

[future] 能否增加以下功能

  • dynamic path with htpasswd via username [http auth]
  • web gui/api [dragdrop] upload file

默认不启用rule_sample/rule_allow_CORS

通过代理不能下载appstore的软件

在苹果手机里的无线设置中,手动设置了wifi的http代理为anyproxy的代理服务器地址,能正常上网,但发现一个问题:可以浏览appstore里的应用,但不能下载,把代理去掉就可以下载了,能否修复这个问题?

下载图片会出现下载一半不能继续下载的情况……

使用了 --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;
    }

};

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.