mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-06-05 16:58:22 +00:00
update readme ,, tr
This commit is contained in:
parent
c6eb2fa892
commit
953b11dbd0
14
README.md
14
README.md
@ -1,7 +1,19 @@
|
||||
http-proxy
|
||||
==========
|
||||
|
||||
A nodejs proxy like charles/fiddler, which generates child certificates for all domains automatically. Any https requests can easily go through this proxy.
|
||||
## Intro
|
||||
While there are lots of proxy written by nodejs in github, most of them can not handle users' HTTPS requests perfectly. A typical problem is that the browser will throw some warning like INVALID_CERTIFICATE when some https requests are sent.
|
||||
|
||||
A simple and fast solution is to short the traffic between the user and the target server. That is to say, what the proxy do is to forward all the traffic of both sides, without intercepting or looking inside.
|
||||
This is useful when you want to establish a standard proxy and do some forwarding tasks. But this can also be useless when using as a debug tool.
|
||||
|
||||
To work as a debug tool of HTTPS, the proxy itself should do two things : intercept the request and cheat the browser with a valid certificate. This is what you know as the man-in-the-middle attack.
|
||||
In order to have a browser-trusted certificate, we would sign certificates dynamically. The first thing to do is to generate a self-signed root CA and import to the system keychain. After trusting this CA, all child certs signed by it can be naturally trusted by the browser.
|
||||
What this proxy do is to generate and replace a temporary cert for any domain if neccessary. Using it, we can intercept all the https requests for debug. BTW, this is also what the charlse/fiddler do when you check the HTTPS_PROXY in preference settings.
|
||||
|
||||
## Feature
|
||||
* can work as http or https proxy
|
||||
* generate and intercept https requests for any domain without complaint by browser (only after you trust its root CA)
|
||||
|
||||
## how to use
|
||||
### step 0 - setup env
|
||||
|
10
index.js
10
index.js
@ -10,11 +10,10 @@ var http = require('http'),
|
||||
program = require('commander');
|
||||
|
||||
program
|
||||
.option('-h, --host [value]', 'hostname for https proxy, localhost for default')
|
||||
.option('-u, --url [value]', 'hostname for https proxy, localhost for default')
|
||||
.option('-t, --type [value]', 'http|https,http for default')
|
||||
.option('-p, --port [value]', 'proxy port, 8001 for default')
|
||||
.option('-c, --clear', 'clear all the tmp certificates')
|
||||
.option('-h, --help', 'print help info')
|
||||
.parse(process.argv);
|
||||
|
||||
var PROXY_PORT = program.port || 8001,
|
||||
@ -23,13 +22,15 @@ var PROXY_PORT = program.port || 8001,
|
||||
PROXY_TYPE = /https/i.test(program.type)? T_PROXY_HTTPS : T_PROXY_HTTP;
|
||||
HOSTNAME = program.host || "localhost";
|
||||
|
||||
|
||||
var count = 0;
|
||||
if(program.clear){
|
||||
exec("rm -rf ./cert/tmpCert",function(){
|
||||
console.log("certificates cleared");
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
}else if(program.help){
|
||||
}else if(program.help && false){ //TODO
|
||||
program.help();
|
||||
|
||||
}else{
|
||||
@ -83,9 +84,6 @@ if(program.clear){
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function dealProxyUserHttpReq(req,res){
|
||||
var urlPattern = url.parse(req.url);
|
||||
var options = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user