Overview
Why another proxy tool?
Nginx's if condition
syntax sucks, and I need more flexibility.
Writing coffeescript is much much better than learning
another javascript like config-language with no debugging break point.
Performance
I think this may be true Apache < proxy-kit < nginx
.
So it may won't be a bad idea to use it behind a nginx server.
Install
npm install proxy-kit
Quick Start
Reverse Proxy
Proxy_kit = require 'proxy-kit' proxy_kit = port: 80 proxy_kitadd Proxy_kitreverse_proxy 'http://one.ysmood.org:8013'
Prefix Proxy
Under the main namespace there's a predefined function prefix_proxy
, we use it for demo.
Proxy_kit = require 'proxy-kit' proxy_kit = port: 80 proxy_kitadd Proxy_kitprefix_proxy 'http://one.ysmood.org:8013' '/prefix'
Then when client visit http://one.ysmood.org/prefix/index?q=10
,
the server behind the proxy will get http://one.ysmood.org:8013/index?q=10
without the word prefix
.
Useful when you only have one subdomain name, and want to bind it to multiple servers.
Road Map
-
Add more handy functions to the kit.
-
Error handling.