Proxy-The-World
可能是『最』易用的静态资源代理工具, 简单的配置,就能启动一个属于你自己的代理服务,代理从未如此简单。 支持 HTTPS 代理,支持阿里 cdn 的 combo 资源代理。代理的 url 对象符合 Node.js 的规范。
优点
- 配置简单,只有三个配置项
- 支持 HTTPS
- 支持 阿里 cdn 的 combo 资源代理
- 不需要再配置反向代理地址,本代理对没有匹配到的请求,一律会根据 url 反查 dns 的服务器地址,自动代理到线上资源
如何使用
const proxy = const path = const fs = const options = ssl: key: fs cert: fs // string || boolean || function || regexp { return true } // object || function { if /log/ return protocol: 'file:' // https | http | file hostname: '' port: '' path: path else return protocol: 'http' // https: | http: | file: hostname: 'g.alicdn.com' port: 80 pathname: urlObjectpathname }
访问下图两个链接,说明代理服务器启动成功
options 说明
Property | Description | Default | Type |
---|---|---|---|
ssl | 自己生成的证书以及公私钥地址 | {} | Object |
from | 设置代理规则 | true | String | Object | Function |
target | 满足 from 设置代理规则的 url 被转发的地址 | { protocol: 'file', path: './build' } | Object | Function |
具体用法,请参考 examples
TODO:
- 测试用例
- Eslint
- 支持命令行指定参数启动
- 集成到开发环境中使用