Node HTTP Proxy 403 Post Request Forbidden -


i used node-http-proxy proxy request port sample.com:80 port sample.com:8080 sample below:

var httpproxy = require('http-proxy');  httpproxy.createserver(8080, 'localhost').listen(80);  http.createserver(function (req, res) {   res.writehead(200, { 'content-type': 'text/plain' });   res.write('request proxied!' + '\n' + json.stringify(req.headers, true, 2));   res.end(); }).listen(9000); 

when do: curl post sample.com:80, 403 forbidden response. when curl get, 301 permanent redirect. question is:

is possible make post , behaves same, always return 200 status code instead of 403 or 301?

thanks

var fmt = require('fmt'); var httpproxy = require('http-proxy');  fmt.sep(); console.log(); fmt.title("\033[1;36mproxy server started\033[0m"); console.log(); fmt.field("\033[1;34mproxy port\033[0m", 80); fmt.field("\033[1;34mtarget port\033[0m", 8080); fmt.field("\033[1;34mtarget address\033[0m", '127.0.0.1');  var server = httpproxy.createserver(function(req, res, proxy) {     proxy.proxyrequest(req, res, { host: '127.0.0.1', port: 8080, buffer: httpproxy.buffer(req) });      var reqbody = '';      req.on('data', function(chunk)     {         reqbody += chunk;     });      req.on('end', function()     {         console.log();         fmt.sep();         console.log();         fmt.title("\033[1;36mrequest shared cloud\033[0m");         console.log();         fmt.dump(req.connection.remoteaddress, "\033[1;35maddress\033[0m");         console.log();         fmt.msg("\033[1;35mheaders\033[0m :");         fmt.dump(req.headers);         console.log();         fmt.msg("\033[1;35mbody\033[0m :");         fmt.dump(reqbody);         console.log();     }); });  server.proxy.on('proxyerror', function(err, req, res) {     fmt.title("\033[1;36mproxy status\033[0m");     console.log();     fmt.dump('failed proxy on port ' + 8080, "\033[1;31merror\033[0m");     res.end(); });  server.proxy.on('end', function() {     fmt.title("\033[1;36mproxy status\033[0m");     console.log();     fmt.dump('request proxied successfully', "\033[1;33mstatus\033[0m"); });  server.listen(80); 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -