mirror of https://github.com/pelias/docker.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
941 B
36 lines
941 B
var net = require("net"); |
|
|
|
// copied from https://github.com/acroca/http-docker-debug-proxy |
|
// credit: https://github.com/acroca |
|
|
|
var host = process.env["HOST"]; |
|
var port = process.env["PORT"]; |
|
var bindPort = process.env["BIND"] || 8000; |
|
|
|
proxy = net.createServer(function(socket){ |
|
var client; |
|
console.log('**** Client connected to proxy'); |
|
|
|
client = net.connect({port: port, host: host}); |
|
|
|
clientToServer = socket.pipe(client) |
|
serverToClient = clientToServer.pipe(socket); |
|
|
|
socket.on('close', function () { |
|
console.log('**** Client disconnected from proxy'); |
|
}); |
|
socket.on('error', function (err) { |
|
console.log('Error: ' + err.soString()); |
|
}); |
|
|
|
socket.on('data', function(d) { |
|
var s = d.toString() |
|
console.log("=> " + s.replace(/\n/g, "\n=> ")) |
|
}) |
|
clientToServer.on('data', function(d) { |
|
var s = d.toString() |
|
console.log("<= " + s.replace(/\n/g, "\n<= ")) |
|
}) |
|
|
|
}) |
|
proxy.listen(bindPort)
|
|
|