mirror of https://github.com/pelias/docker.git
Peter Johnson
6 years ago
3 changed files with 63 additions and 0 deletions
@ -0,0 +1,3 @@
|
||||
FROM node:0.12 |
||||
ADD script.js /script.js |
||||
CMD ["node", "/script.js"] |
@ -0,0 +1,24 @@
|
||||
|
||||
HTTP debugging proxy |
||||
|
||||
## Usage |
||||
|
||||
```yaml |
||||
debugproxy: |
||||
image: pelias/debug-proxy:latest |
||||
container_name: debugproxy |
||||
restart: always |
||||
environment: [ "HOST=placeholder", "PORT=4100" ] |
||||
ports: [ "8000:8000" ] |
||||
``` |
||||
|
||||
## Rebuild image |
||||
|
||||
```bash |
||||
docker build -t pelias/debug-proxy . |
||||
``` |
||||
|
||||
## Credit |
||||
|
||||
Source code copied from: |
||||
https://github.com/acroca/http-docker-debug-proxy |
@ -0,0 +1,36 @@
|
||||
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) |
Loading…
Reference in new issue