Browse Source

feat(debug-proxy): add http debug proxy image

debug-proxy
Peter Johnson 6 years ago
parent
commit
55e0e21377
  1. 3
      images/debug-proxy/Dockerfile
  2. 24
      images/debug-proxy/README.md
  3. 36
      images/debug-proxy/script.js

3
images/debug-proxy/Dockerfile

@ -0,0 +1,3 @@
FROM node:0.12
ADD script.js /script.js
CMD ["node", "/script.js"]

24
images/debug-proxy/README.md

@ -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

36
images/debug-proxy/script.js

@ -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…
Cancel
Save