http-proxy-cache
v1.1.3
Published
A caching HTTP forward proxy.
Downloads
5
Maintainers
Readme
http-proxy-cache
A caching HTTP forward proxy.
Features:
- 100% transparent
- Keeps consistent header order similar to Google Chrome (see
headerOrder
in index.js) - Ensures all headers sent to the target is properly cased (e.g.
User-Agent
instead ofuser-agent
) - Stores all 200 responses in a MongoDB database
- Forwards all requests to the target by default (i.e. cache not used)
- Prefers the content in the cache if the
X-Cache-Preferred
header is present (this header is never sent to the target) - If environment variable
PROXY_AUTH
is set, the proxy will reject all incoming requests that doesn't have a headerX-Proxy-Auth
with the same value
Prerequisites
- MongoDB - Use the environment variable
MONGO_URI
to specify connection string (defaults to:localhost/http-proxy-cache
) - Optional: Opbeat account for error logging configured using environment variables
Installation
npm install http-proxy-cache -g
Start
To start the proxy, simply run:
http-proxy-cache
Example usage
This is an example app that uses the request module to perform a HTTP request via the proxy to httpbin which will echo the HTTP request back as the reponse body:
var request = require('request')
request({
uri: 'http://httpbin.org/get',
proxy: 'http://<your-proxy-domain-here>'
}, function (err, res, body) {
if (err) throw err
console.log(body)
})
Debug
Set the environment variable DEBUG=proxy
to enable debug mode.
License
MIT