I want to set up proxy for some XYZ server whose i am not the admin.
Then i want to do some analysis over the request and response headers then also over request and response bodies.
So i am using http-proxy https://github.com/nodejitsu/node-http-proxy
this is what i am doing :
var proxy = httpProxy.createProxyServer();
connect.createServer(
connect.bodyParser(),
require('connect-restreamer')(),
function (req, res) {
proxy.web(req, res, { target : 'XYZserver' });
}
).listen(config.listenPort);
Upto GET request everything is fine but whenever a request with some body like POST, PATCH, PUT etc request are made i get the error :
Error: socket hang up
at createHangUpError (http.js:1472:15)
at Socket.socketCloseListener (http.js:1522:23)
at Socket.EventEmitter.emit (events.js:95:17)
at TCP.close (net.js:466:12)
I google a lot but found no clue whats wrong going on.
I enable socket proxy with 'ws:true' option of 'proxy.web' but still the same error.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…