bfn-proxy
HTTP request proxy middleware for node.js
Designed to be the simplest way possible to proxy http calls.
Features
- Small footprint
- Responses are unmodified (only headers are modified)
- Built for browser use (url-relative/root-relative resources work)
- Great for testing your website at proxy location
- Great for grabbing a screen shot of your website from proxy location
Install
$ npm install --save bfn-proxy
Examples
vanilla http server
Simple app. If created on heroku, go to https://applicationname.herokuapp.com/twitter.com/
require('http')
.createServer(require('bfn-proxy')())
.listen(process.env.PORT || 8080)
express/connect simple
Simple app using middleware, i.e. http://servername.com/ipecho.net/plain
var express = require('express')
var pxy = require('bfn-proxy')()
var app = express()
app.use(pxy)
express/connect advanced
Only allow access from your local server with URI prefix '/pxy', i.e. http://127.0.0.1/pxy/www.bluefidelity.com/
var express = require('express')
var pxy = require('bfn-proxy')()
var app = express()
app.use('/pxy/', function (req, res, next) {
if (req.connection.remoteAddress !== '127.0.0.1') {
return next(new Error('Bad authentication data'))
}
pxy(req, res)
})
TODO
License
MIT