Skip to content
HTTP Proxy that searches for Host header and avoids any parsing
Latest commit 7de8f79 Apr 19, 2013 @mikeal 0.1.1
Failed to load latest commit information.
tests Initial commit. Apr 19, 2013 Initial commit. Apr 19, 2013
index.js Initial commit. Apr 19, 2013
package.json 0.1.1 Apr 19, 2013

Pure TCP HTTP Proxy

hostproxy is a pure TCP proxy for HTTP. It does not fully parse HTTP, it simply searches for the Host header and injects other headers in to the stream.


var hostproxy = require('hostproxy')
  , net = require('net')

hostproxy(function (host) {
  if (host === '') return net.connect(80, '')
  return net.connect(80, '')

If no host header is present then host will be null.

hostproxy(function (host) {
  if (!host) return // returning nothing will force disconnect the client
  return net.connect(80, host)

What about adding headers?

hostproxy(function (host, addHeader, address) {
  addHeader('x-forwarded-for', address.address)
  return net.connect(80, host || '')

The address param is the return value from socket.address().

Something went wrong with that request. Please try again.