node-http-proxy wrapper

npm install patron
20 downloads in the last week
40 downloads in the last month

Patron Build Status

Wrapper around node-http-proxy with plugins, logging, and simple configuration format.


npm install patron


var createProxyServer = require('patron');

var router = {
    // url based proxying support
    '': 'localhost:3000',
    // by default proxy only http
    '': 'localhost:4000',
    // proxy both http and websocket
    '': {to: 'localhost:5000', ws:true},
    // order is respected, thas't important
    // if define just domain first, it wiil ignore all next defined domain/url
    '': 'localhost:6780',
    // proxy only websockets
    '': {to: 'localhost:6000', ws:true, http: false},
    // custom logic support
    '': function(net, proxy) {
      if (net.req.url == '/bla') {
        // proxy based on url
        return proxy(net, 'localhost:6778')
      else if (net.req.url == '/test') {
        // url rewrite
        net.req.url = '/rewrite/url'
        // websocket support
        return proxy(net, 'localhost:6712')
    '': function(net, proxy) {
      // inline responce
      return net.res.end('Error')




Router is an object where key is rule and value is action. Rule is always a string. Host with or without url part Action can be:

  • simple string like host:port
  • object like {to: 'host:port', ws:true, http:false} by default ws is false, http is true
  • function, witch accepts 2 arguments
    • object net {req:http.request, res:http.responce, protocol:string}
    • function proxy witch accepts net object and string 'host:port'


npm loves you