node-http-proxy

Load balancing with node.js using http-proxy

我的未来我决定 提交于 2019-11-27 16:20:12
问题 I'm trying to code a loadbalancing with node.js and http-proxy. I want a loadBalancer which share incoming request treatment between 2 servers. var http = require('http'), httpProxy = require('http-proxy'); var servers = [{host :'127.0.0.1', port :3000}, {host : 'remote_adr',port :3000}]; httpProxy.createServer(function (req, res, proxy) { var target = servers.shift(); proxy.proxyRequest(req, res, target); servers.push(target); }).listen(8000); I thought that doing this, it would have made a

Node http-proxy and express

一世执手 提交于 2019-11-27 05:32:03
问题 I'm trying to do something like this: // Setup prox to handle blog requests httpProxy.createServer({ hostnameOnly: true, router: { 'http://localhost': '8080', 'http://localhost/blog': '2368' } }).listen(8000); Previously I was using this: http.createServer(app).listen(app.get('port'), function(){ console.log("Express server listening on port " + app.get('port')); }); Basically, I want to still use express... but, when people go to http://localhost/blog get taken to the blog but still be

Rewrite response headers with node-http-proxy

那年仲夏 提交于 2019-11-27 02:15:53
问题 I'm using node-http-proxy and want to watch for a particular response header and rewrite it if necessary. Anyone here have suggestions on to do this? My proxy server sits in front of a couple different node servers as well as a java webapp. The java app is setting a cookie, but the cookie has a path that is relative the the webapp's context. I need the cookie to be secure and have a path to root without modifying the Java application. In other words, the following header is returned: set