Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Simple reverse proxy server

  • Loading branch information...
commit 79a86631e28e92211f5e8ef7eb87cdd13ec23b5a 1 parent 045c1d2
@pquerna authored
Showing with 24 additions and 0 deletions.
  1. +24 −0 limiting_concurrency/server_nolimit.js
View
24 limiting_concurrency/server_nolimit.js
@@ -2,3 +2,27 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND. See the accompanying
* LICENSE file.
*/
+
+var http = require('http');
+var sys = require('sys');
+var destination = "nodejs.org";
+
+http.createServer(function(req, res) {
+ var proxy = http.createClient(80, destination);
+ var preq = proxy.request(req.method, req.url, req.headers);
+
+ preq.on('response', function(pres) {
+ res.writeHead(pres.statusCode, pres.headers);
+ sys.pump(pres, res);
+ pres.on('end', function() {
+ preq.close();
+ res.close();
+ })
+ });
+ req.on('data', function(chunk) {
+ preq.write(chunk, 'binary');
+ });
+ req.on('end', function() {
+ preq.end();
+ });
+}).listen(8080);
Please sign in to comment.
Something went wrong with that request. Please try again.