Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions images/debug-proxy/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM node:0.12
ADD script.js /script.js
CMD ["node", "/script.js"]
24 changes: 24 additions & 0 deletions images/debug-proxy/README.md
Original file line number Diff line number Diff line change
@@ -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 changes: 36 additions & 0 deletions images/debug-proxy/script.js
Original file line number Diff line number Diff line change
@@ -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)