This is a simple, minimally modifiable HTTP tunneling proxy written in Node.js. It is based on a snippet available in the Node.js docs. The module exposes a single function and a CLI application for launching a local proxy.
http-tunneling-proxy [--port p] [--host h]
This command will spawn a local HTTP tunneling proxy, bound to the specified
port and hostname. Port defaults to 3030
, while host defaults to 127.0.0.1
.
createProxyServer([callback])
This method will return a fresh, unbound
http.Server
instance that can be bound via listen()
. The callback function
will be called at each request:
const createProxyServer = require('http-tunneling-proxy')
const onRequest = req => console.log(`${req.method} ${req.url}`)
const proxyServer = createProxyServer(onRequest)
proxyServer.on('error', e => console.error('proxyServer error', e))
const port = 3030
proxyServer.listen(port)
console.log('listening on port:', port)