Package Exports
- hiproxy
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (hiproxy) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
hiproxy
hiproxy is a lightweight Node.js proxy client with hosts and nginx-like config support.
Install
npm install -g hiproxyUsage
CLI
- Start proxy server
cd your_workspace
hiproxy start -p 5525 --debug- Config proxy
127.0.0.1:5525Node.js API
var HiProxyServer = require('hiproxy');
var proxy = new HiProxyServer(8848, 10086);
// events
proxy.on('request', function(req, res){
req.someThing = 'some thing';
console.log('new request =>', req.method, req.url);
});
proxy.on('data', function(data){
console.log('on response =>', data.toString());
});
proxy.start().then(function (servers) {
console.log('proxy server started at: 127.0.0.1:8848');
});
// stop proxy server
// proxy.stop();
// restart proxy server
// proxy.restart();CLI commands and options
Commands and global options
Commands:
start Start a local proxy server
stop Stop the local proxy server
reload Restart the local proxy server (In development)
state Show all the servers state
open Open browser and set proxy (In development)
Options:
-v, --version 显示版本信息
-h, --help 显示帮助信息
-D, --daemon 后台运行
--log-dir 后台运行时日志存放路径(绝对路径),默认为用户目录
--log-time 显示日志时间
--log-level 过滤日志级别,只有指定级别的日志才会显示
--grep <content> 过滤日志内容,只有保护过滤字符串的日志才会显示Command help
start
USAGE:
start [--port <port>] [-xodD]
DESCRIBE:
启动代理服务
OPTIONS:
-h, --help show help info
-p, --port <port> http代理服务端口号
-s, --https 启动https代理服务
-m, --middle-man-port <port> https中间人端口号
-o, --open [browser] 打开浏览器窗口
--pac-proxy 是否使用自动代理,如果使用,不在hosts或者rewrite规则中的域名不会走代理Documentation
hosts config example
hiproxy supports enhanced version of hosts,
the hosts file supports not only IP but also port numbers.
# comment
127.0.0.1 example.com
127.0.0.1:8800 blog.example.com life.example.comrewrite config example
set $port 8899;
set $ip 127.0.0.1;
set $online 210.0.0.0;
domain example.com {
location / {
proxy_pass http://$online/;
}
location /blog/ {
proxy_pass http://$ip:$port/blog/;
proxy_set_header from 'hiproxy';
set_header proxy 'hiproxy';
}
}Running example
cd example
node index.js- url => http://test.com
Running tests
npm testLicense
MIT