gzip encoding #18

mdornseif opened this Issue Dec 4, 2010 · 7 comments


None yet

5 participants


It would be awesome if node-http-proxy could gzip the responses so I could use it to add gzip capability do an "not-so-modern" backend server.




Is this functionality best suited to be in the proxy code itself? Shouldn't gzip be implemented as a middle-ware? Do other proxy projects suppor this?

Any additional insight would be great @mdornsei


I've been gzipping in apache and nginx for years.
I count gzipping in the same league as ssl. You don't want your backends to bother with it.
Replacing nginx with node-http-proxy now for websocket support (among other things).
As a frontend proxy/load balancer replacement, I think it's a good feature to have.

But of course a middleware sounds like an OK place too. Depends a bit on the situation I guess.
In my case, I have multiple languages and stacks sitting behind http-proxy. Finding a middleware for all the frameworks in use sounds like a harder task than keeping it in 1 place.

nodejitsu member

gzip is something that ryan has recently expressed a desire to have in core, so a streaming gzip parser for node is a top priority!


You could use connect-gzip to do the dirty work:

var http = require('http'),
  gzip = require('connect-gzip'),
  httpProxy = require('http-proxy');

var gzip_f = gzip.gzip();
var proxy = new httpProxy.HttpProxy();

// dummy server
http.createServer(function (req, res) {
  res.writeHead(200, { 'Content-Type': 'text/plain' });
  res.write('hello gzipped content\n');

// proxy server
http.createServer(function(req, res) {
  gzip_f(req, res, function(){});
  proxy.proxyRequest(req, res, {
    host: 'localhost',
    port: 8000
nodejitsu member

Closing this since gzip is supported now with http-proxy middlewares: https://github.com/nodejitsu/node-http-proxy/blob/master/examples/gzip-middleware.js

@indexzero indexzero closed this Aug 28, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment