Skip to content

Instantly share code, notes, and snippets.

@Filirom1
Last active February 2, 2018 16:01
Show Gist options
  • Save Filirom1/68de8b6af955b45d36d2 to your computer and use it in GitHub Desktop.
Save Filirom1/68de8b6af955b45d36d2 to your computer and use it in GitHub Desktop.
Hoxy Proxy

http://greim.github.io/hoxy/

$ scl enable nodejs010 'npm i  hoxy'
$ scl enable nodejs010 'node proxy.js' &
$ rhc apps --header 'X-Remote-User:demo' --server http://localhost:1337/

request made to:  { 'x-remote-user': 'demo',
  accept: 'application/json',
  'user-agent': 'rhc/1.30.2 (ruby 1.8.7; x86_64-linux) (API 1.11.21.31.41.51.61.7) (2.4.0, ruby 1.8.7 (2011-06-30))',
  date: 'Fri, 19 Sep 2014 12:34:55 GMT',
  host: 'localhost:8080' } /broker/rest/api GET
request made to:  { 'x-remote-user': 'demo',
  accept: 'application/json;version=1.7',
  'user-agent': 'rhc/1.30.2 (ruby 1.8.7; x86_64-linux) (API 1.11.21.31.41.51.61.7) (2.4.0, ruby 1.8.7 (2011-06-30))',
  date: 'Fri, 19 Sep 2014 12:34:55 GMT',
  host: 'localhost:8080' } /broker/rest/api GET

# openssl genrsa -out private.key 1024
# openssl req -x509 -new -nodes -key private.key -days 1024 -out cert.pem -subj "/C=US/ST=Utah/L=Provo/O=ACME Signing Authority Inc/CN=example.com"
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
var hoxy = require('hoxy');
var fs = require('fs')
var proxy = hoxy.createServer({
reverse: 'http://10.98.45.6',
tls: {
key: fs.readFileSync('./private.key'),
cert: fs.readFileSync('./cert.pem')
}
}).listen(1337);
proxy.intercept({phase: 'request', 'as': 'string'}, function(req, resp){
console.log('Request: ', req.headers, req.url, req.method);
console.log(req.string)
});
proxy.intercept({phase: 'response', 'as': 'string'}, function(req, resp){
console.log('Reponse:')
console.log(resp.string)
});
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
var hoxy = require('hoxy');
var proxy = new hoxy.Proxy({
reverse: 'http://localhost:8080'
}).listen(1337);
proxy.intercept('request', function(req, resp){
console.log('request made to: ', req.headers, req.url, req.method);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment