From 635a51bc3379619a87aa58f412fde4174cc58976 Mon Sep 17 00:00:00 2001 From: alexyan <5918760@gmail.com> Date: Wed, 26 Nov 2014 14:09:34 +0800 Subject: [PATCH] Create gh-pages branch via GitHub --- index.html | 12 +++++++++++- params.json | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index e99a807..3857e83 100644 --- a/index.html +++ b/index.html @@ -244,6 +244,16 @@

Hosted on GitHub Pages — Theme by orderedlist

- + + + \ No newline at end of file diff --git a/params.json b/params.json index 799d4ca..f24d133 100644 --- a/params.json +++ b/params.json @@ -1 +1 @@ -{"name":"Anyproxy","tagline":"A fully configurable proxy in NodeJS, which can handle HTTPS requests perfectly.","body":"anyproxy\r\n==========\r\nA fully configurable proxy in NodeJS, which can handle HTTPS requests perfectly.\r\n\r\nFeature\r\n------------\r\n* work as http or https proxy\r\n* fully configurable, you can modify a request at any stage by your own javascript code\r\n* when working as https proxy, it can generate and intercept https requests for any domain without complaint by browser (after you trust its root CA)\r\n* provide a web interface\r\n\r\n![screenshot](http://gtms03.alicdn.com/tps/i3/TB1ddyqGXXXXXbXXpXXihxC1pXX-1000-549.jpg_640x640q90.jpg)\r\n \r\nUsage\r\n--------------\r\n\r\n### step 1 - install\r\n\r\n* install [NodeJS](http://nodejs.org/)\r\n* ``npm install -g anyproxy`` , may require ``sudo``\r\n\r\n### step 2 - start server\r\n\r\n* start with default settings : ``anyproxy``\r\n* start with a specific port: ``anyproxy --port 8001``\r\n\r\n### step 3 - launch web interface\r\n\r\n* visit [http://127.0.0.1:8002](http://127.0.0.1:8002) with modern browsers\r\n\r\nHow to write your own rule file\r\n-------------------\r\n* with rule file, you can modify a request at any stage, no matter it's just before sending or after servers' responding.\r\n* actually ruleFile.js is a module for Nodejs, feel free to invoke your own modules.\r\n* ``anyproxy --rule /path/to/ruleFile.js``\r\n* you may learn how it works by our samples: [https://github.com/alipay-ct-wd/anyproxy/tree/master/rule_sample](https://github.com/alipay-ct-wd/anyproxy/tree/master/rule_sample)\r\n* samples in [rule_sample](https://github.com/alipay-ct-wd/anyproxy/tree/master/rule_sample)\r\n * **rule__blank.js**, blank rule file with some comments. You may read this before writing your own rule file.\r\n\r\n * **rule_adjust_response_time.js**, delay all the response for 1500ms\r\n * **rule_allow_CORS.js**, add CORS headers to allow cross-domain ajax request\r\n * **rule_intercept_some_https_requests.js**, intercept https requests toward github.com\r\n * **rule_remove_cache_header.js**, remove all cache-related headers from server\r\n * **rule_replace_request_option.js**, replace request parameters before sending to the server\r\n * **rule_replace_response_data.js**, modify response data\r\n * **rule_replace_response_status_code.js**, replace server's status code\r\n * **rule_use_local_data.js**, map some requests to local file\r\n\r\n* rule file scheme is as follows, you may also get it from [rule__blank.js](https://github.com/alipay-ct-wd/anyproxy/blob/master/rule_sample/rule__blank.js)\r\n\r\n```javascript\r\n\r\nmodule.exports = {\r\n /*\r\n these functions will overwrite the default ones, write your own when necessary.\r\n */\r\n\r\n //whether to intercept this request by local logic\r\n //if the return value is true, anyproxy will call dealLocalResponse to get response data and will not send request to remote server anymore\r\n shouldUseLocalResponse : function(req,reqBody){\r\n return false;\r\n },\r\n\r\n //you may deal the response locally instead of sending it to server\r\n //this function be called when shouldUseLocalResponse returns true\r\n //callback(statusCode,resHeader,responseData)\r\n //e.g. callback(200,{\"content-type\":\"text/html\"},\"hello world\")\r\n dealLocalResponse : function(req,reqBody,callback){\r\n callback(statusCode,resHeader,responseData)\r\n },\r\n\r\n //replace the request protocol when sending to the real server\r\n //protocol : \"http\" or \"https\"\r\n replaceRequestProtocol:function(req,protocol){\r\n var newProtocol = protocol;\r\n return newProtocol;\r\n },\r\n\r\n //req is user's request sent to the proxy server\r\n //option is how the proxy server will send request to the real server. i.e. require(\"http\").request(option,function(){...})\r\n //you may return a customized option to replace the original option\r\n //you should not write content-length header in options, since anyproxy will handle it for you\r\n replaceRequestOption : function(req,option){\r\n var newOption = option;\r\n return newOption;\r\n },\r\n\r\n //replace the request body\r\n replaceRequestData: function(req,data){\r\n return data;\r\n },\r\n\r\n //replace the statusCode before it's sent to the user\r\n replaceResponseStatusCode: function(req,res,statusCode){\r\n var newStatusCode = statusCode;\r\n return newStatusCode;\r\n },\r\n\r\n //replace the httpHeader before it's sent to the user\r\n //Here header == res.headers\r\n replaceResponseHeader: function(req,res,header){\r\n var newHeader = header;\r\n return newHeader;\r\n },\r\n\r\n //replace the response from the server before it's sent to the user\r\n //you may return either a Buffer or a string\r\n //serverResData is a Buffer, you may get its content by calling serverResData.toString()\r\n replaceServerResData: function(req,res,serverResData){\r\n return serverResData;\r\n },\r\n\r\n //add a pause before sending response to user\r\n pauseBeforeSendingResponse : function(req,res){\r\n var timeInMS = 1; //delay all requests for 1ms\r\n return timeInMS; \r\n },\r\n\r\n //should intercept https request, or it will be forwarded to real server\r\n shouldInterceptHttpsReq :function(req){\r\n return false;\r\n }\r\n\r\n};\r\n\r\n```\r\n\r\nUsing https features\r\n----------------\r\n#### step 1 - install openssl\r\n* install [openssl](http://wiki.openssl.org/index.php/Compilation_and_Installation) ,if you want to use HTTPS-related features. After that, the command ``openssl`` should be exposed to your shell\r\n\r\n#### step 2 - generate a rootCA and trust it\r\n* you should do this when it is the first time to start anyproxy\r\n* execute ``anyproxy --root`` ,follow the instructions on screen\r\n* you will see some tip like *rootCA generated at : /usr/lib...* . ``cd`` to that directory, add/trust the rootCA.crt file to your system keychain. In OSX, you may do that by open the *crt file directly\r\n\r\n#### step 3 - start a https proxy\r\n* ``anyproxy --type https --host my.domain.com``\r\n* the param ``host`` is required with https proxy and it should be kept exactly what it it when you config your browser. Otherwise, you may get some warning about security.\r\n\r\n\r\nOthers\r\n-----------------\r\n#### work as a module\r\n```\r\nnpm install anyproxy --save\r\n```\r\n\r\n```javascript\r\nvar proxy = require(\"anyproxy\");\r\n\r\n!proxy.isRootCAFileExists() && proxy.generateRootCA(); //please manually trust this rootCA\r\nnew proxy.proxyServer(\"http\",\"8001\", \"localhost\" ,\"path/to/rule/file.js\");\r\n\r\n```\r\n\r\n#### clear all the temperary certificates\r\n``anyproxy --clear``\r\n\r\n\r\n## Contact\r\n* Please feel free to raise any issue about this project, or give us some advice on this doc. :)\r\n","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."} \ No newline at end of file +{"name":"Anyproxy","tagline":"A fully configurable proxy in NodeJS, which can handle HTTPS requests perfectly.","body":"anyproxy\r\n==========\r\nA fully configurable proxy in NodeJS, which can handle HTTPS requests perfectly.\r\n\r\nFeature\r\n------------\r\n* work as http or https proxy\r\n* fully configurable, you can modify a request at any stage by your own javascript code\r\n* when working as https proxy, it can generate and intercept https requests for any domain without complaint by browser (after you trust its root CA)\r\n* provide a web interface\r\n\r\n![screenshot](http://gtms03.alicdn.com/tps/i3/TB1ddyqGXXXXXbXXpXXihxC1pXX-1000-549.jpg_640x640q90.jpg)\r\n \r\nUsage\r\n--------------\r\n\r\n### step 1 - install\r\n\r\n* install [NodeJS](http://nodejs.org/)\r\n* ``npm install -g anyproxy`` , may require ``sudo``\r\n\r\n### step 2 - start server\r\n\r\n* start with default settings : ``anyproxy``\r\n* start with a specific port: ``anyproxy --port 8001``\r\n\r\n### step 3 - launch web interface\r\n\r\n* visit [http://127.0.0.1:8002](http://127.0.0.1:8002) with modern browsers\r\n\r\nHow to write your own rule file\r\n-------------------\r\n* with rule file, you can modify a request at any stage, no matter it's just before sending or after servers' responding.\r\n* actually ruleFile.js is a module for Nodejs, feel free to invoke your own modules.\r\n* ``anyproxy --rule /path/to/ruleFile.js``\r\n* you may learn how it works by our samples: [https://github.com/alipay-ct-wd/anyproxy/tree/master/rule_sample](https://github.com/alipay-ct-wd/anyproxy/tree/master/rule_sample)\r\n* samples in [rule_sample](https://github.com/alipay-ct-wd/anyproxy/tree/master/rule_sample)\r\n * **rule__blank.js**, blank rule file with some comments. You may read this before writing your own rule file.\r\n\r\n * **rule_adjust_response_time.js**, delay all the response for 1500ms\r\n * **rule_allow_CORS.js**, add CORS headers to allow cross-domain ajax request\r\n * **rule_intercept_some_https_requests.js**, intercept https requests toward github.com\r\n * **rule_remove_cache_header.js**, remove all cache-related headers from server\r\n * **rule_replace_request_option.js**, replace request parameters before sending to the server\r\n * **rule_replace_response_data.js**, modify response data\r\n * **rule_replace_response_status_code.js**, replace server's status code\r\n * **rule_use_local_data.js**, map some requests to local file\r\n\r\n* rule file scheme is as follows, you may also get it from [rule__blank.js](https://github.com/alipay-ct-wd/anyproxy/blob/master/rule_sample/rule__blank.js)\r\n\r\n```javascript\r\n\r\nmodule.exports = {\r\n /*\r\n these functions will overwrite the default ones, write your own when necessary.\r\n */\r\n\r\n //whether to intercept this request by local logic\r\n //if the return value is true, anyproxy will call dealLocalResponse to get response data and will not send request to remote server anymore\r\n shouldUseLocalResponse : function(req,reqBody){\r\n return false;\r\n },\r\n\r\n //you may deal the response locally instead of sending it to server\r\n //this function be called when shouldUseLocalResponse returns true\r\n //callback(statusCode,resHeader,responseData)\r\n //e.g. callback(200,{\"content-type\":\"text/html\"},\"hello world\")\r\n dealLocalResponse : function(req,reqBody,callback){\r\n callback(statusCode,resHeader,responseData)\r\n },\r\n\r\n //replace the request protocol when sending to the real server\r\n //protocol : \"http\" or \"https\"\r\n replaceRequestProtocol:function(req,protocol){\r\n var newProtocol = protocol;\r\n return newProtocol;\r\n },\r\n\r\n //req is user's request sent to the proxy server\r\n //option is how the proxy server will send request to the real server. i.e. require(\"http\").request(option,function(){...})\r\n //you may return a customized option to replace the original option\r\n //you should not write content-length header in options, since anyproxy will handle it for you\r\n replaceRequestOption : function(req,option){\r\n var newOption = option;\r\n return newOption;\r\n },\r\n\r\n //replace the request body\r\n replaceRequestData: function(req,data){\r\n return data;\r\n },\r\n\r\n //replace the statusCode before it's sent to the user\r\n replaceResponseStatusCode: function(req,res,statusCode){\r\n var newStatusCode = statusCode;\r\n return newStatusCode;\r\n },\r\n\r\n //replace the httpHeader before it's sent to the user\r\n //Here header == res.headers\r\n replaceResponseHeader: function(req,res,header){\r\n var newHeader = header;\r\n return newHeader;\r\n },\r\n\r\n //replace the response from the server before it's sent to the user\r\n //you may return either a Buffer or a string\r\n //serverResData is a Buffer, you may get its content by calling serverResData.toString()\r\n replaceServerResData: function(req,res,serverResData){\r\n return serverResData;\r\n },\r\n\r\n //add a pause before sending response to user\r\n pauseBeforeSendingResponse : function(req,res){\r\n var timeInMS = 1; //delay all requests for 1ms\r\n return timeInMS; \r\n },\r\n\r\n //should intercept https request, or it will be forwarded to real server\r\n shouldInterceptHttpsReq :function(req){\r\n return false;\r\n }\r\n\r\n};\r\n\r\n```\r\n\r\nUsing https features\r\n----------------\r\n#### step 1 - install openssl\r\n* install [openssl](http://wiki.openssl.org/index.php/Compilation_and_Installation) ,if you want to use HTTPS-related features. After that, the command ``openssl`` should be exposed to your shell\r\n\r\n#### step 2 - generate a rootCA and trust it\r\n* you should do this when it is the first time to start anyproxy\r\n* execute ``anyproxy --root`` ,follow the instructions on screen\r\n* you will see some tip like *rootCA generated at : /usr/lib...* . ``cd`` to that directory, add/trust the rootCA.crt file to your system keychain. In OSX, you may do that by open the *crt file directly\r\n\r\n#### step 3 - start a https proxy\r\n* ``anyproxy --type https --host my.domain.com``\r\n* the param ``host`` is required with https proxy and it should be kept exactly what it it when you config your browser. Otherwise, you may get some warning about security.\r\n\r\n\r\nOthers\r\n-----------------\r\n#### work as a module\r\n```\r\nnpm install anyproxy --save\r\n```\r\n\r\n```javascript\r\nvar proxy = require(\"anyproxy\");\r\n\r\n!proxy.isRootCAFileExists() && proxy.generateRootCA(); //please manually trust this rootCA\r\nnew proxy.proxyServer(\"http\",\"8001\", \"localhost\" ,\"path/to/rule/file.js\");\r\n\r\n```\r\n\r\n#### clear all the temperary certificates\r\n``anyproxy --clear``\r\n\r\n\r\n## Contact\r\n* Please feel free to raise any issue about this project, or give us some advice on this doc. :)\r\n","google":"UA-57129650-1","note":"Don't delete this file! It's used internally to help with page regeneration."} \ No newline at end of file