flyingfisher / node-http-proxy

A full-featured http proxy for node.js

Home Page:http://github.com/nodejitsu/node-http-proxy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

forked from nodejitsu/node-http-proxy

Add ability to change response script and link relative url when proxy

Add this ability for meteor in this moment (version 0.6.4 still not support ROOT_URL, so I change proxy code to avoid this problem)

This is forked from master, and until now, websocket can not pass through if use node 0.10.X This works fine with websocket under node 0.8.17 which I used now

n is a great node version maintain tool

normal usage:

var httpProxy = require('seafish-http-proxy-meteor');

var options = {
  replaceRelativePath: true,
  pathnameOnly: true,
  router: {
    '/wiki': '127.0.0.1:8001',
    '/blog': '127.0.0.1:8002/blog',
    '/api':  '127.0.0.1:8003'
  }
}

var proxyServer = httpProxy.createServer(options);
proxyServer.listen(80);

meteor usage: before 0.6.6.1

var httpProxy = require('seafish-http-proxy-meteor');

var options = {
  replaceRelativePath: true,
  pathnameOnly: true,
  router: {
    '/meteor': '127.0.0.1:3000',
    '/sockjs': '127.0.0.1:3000/sockjs',
    '/otherapp': '127.0.0.1:8002'
  }
}

var proxyServer = httpProxy.createServer(options);
proxyServer.listen(80);

meteor usage: after 0.6.6.1

// suppose ROOT_URL is "localhost:3000/meteor"
var httpProxy = require('seafish-http-proxy-meteor');

var options = {
  pathnameOnly: true,
  router: {
    '/meteor': '127.0.0.1:3000/meteor',
    '/otherapp': '127.0.0.1:8002'
  }
}

var proxyServer = httpProxy.createServer(options);
proxyServer.listen(80);

Simple use

// suppose ROOT_URL is "localhost:3000"
var httpProxy = require('seafish-http-proxy-meteor');

var options = {
  pathnameOnly: true,
  router: {
    '/otherapp': '127.0.0.1:8002',
    '/': '127.0.0.1:3000/',
  }
}

var proxyServer = httpProxy.createServer(options);
proxyServer.listen(80);

Use with https

// suppose ROOT_URL is "localhost:3000"
var httpProxy = require('seafish-http-proxy-meteor');

var options = {
  pathnameOnly: true,
  router: {
    '/otherapp': '127.0.0.1:8002',
    '/': '127.0.0.1:3000/',
  },
  https: {
    key: "",
    cert: ""
  }
}

var proxyServer = httpProxy.createServer(options);
proxyServer.listen(443);

The replaceRelativePath option, work for html page, change things like

<script src="/test.js"></script>

into

<script src="/path/test.js"></script>

About

A full-featured http proxy for node.js

http://github.com/nodejitsu/node-http-proxy

License:Other


Languages

Language:JavaScript 100.0%