Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1059353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:09:30+00:00 2026-05-16T18:09:30+00:00

I created a little proxy node script, which looksup the request.url and either passes

  • 0

I created a little proxy node script, which looksup the request.url
and either passes a request to my apache server or uses node to
process/response to this request. I have been successful so far,
everything works fine, but when I enable mod_deflate for the apache,
“strange things will happen”.

It looks like node just “cancels” or “stops” a response way to early.
I’m listening on the “data” event from my request, and at some point
node just decides that the response has ended (which is wrong) and
fires the “end” event.

Code snippet:

var apache = http.createClient(82, 'localhost');

function pass_to_apache(req, res){
    var request = apache.request(req.method, req.url, req.headers);

    req.addListener('end', function() {
        request.end();
    });

    req.addListener('data', function(chunk) {
        request.write(chunk);
        sys.puts('writting chunk\n');
    });

    request.addListener('response', function(response) {
        res.writeHead(response.statusCode, response.headers);
        response.addListener('data', function(chunk) {
            sys.puts('writting data..\n');
            res.write(chunk);
        });
        response.addListener('end', function() {
            sys.puts('end of request');
            res.end();
        });
    });
}

var MainServer = http.createServer(function(request, response) {
    sys.puts('received '+request.method+' '+request.url + "\n"+JSON.stringify(request.headers));
    if(/^\/node/.test(request.url)) {
        response.writeHead(200, {'Content-Type': 'text/plain'});
        response.end("Hi, it's node =)\n");
    }
    else if(/^\/exit/.test(request.url)) {
        sys.puts('closing..\n');
        MainServer.close();
        throw new Error('forced');
    }
    else {
        pass_to_apache(request, response);
    }
});

MainServer.listen(80, 'typeofnan.com');

You can “see” this in action at http://www.typeofnan.com && http://www.typeofnan.com/node/anything
edit: disabled nodejs for now.

Remember, this works like a charm if no gzip/deflate is used by the
apache. I tried to set the encoding to “binary” in my reponse, but no
success either.

Am I missing something here ? Can someony confirm this behavior?
I’m using the latest relase (0.2.0).

Is there maybe another (better) solution to use a proxyscript like this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T18:09:31+00:00Added an answer on May 16, 2026 at 6:09 pm

    I’m intrigued. I fired up your code and pointed it at http://www.typeofnan.com. It worked fine, but I noticed that the server was not returning compressed responses. So then I set it to proxy apache.org and my browser also rendered it fine with gzipped content! For a GET on “/”, I got following response headers:

    {"date":"Mon, 13 Sep 2010 11:03:45 GMT","server":"Apache/2.3.8 (Unix) mod_ssl/2.3.8 OpenSSL/1.0.0a","last-modified":"Sat, 11 Sep 2010 19:38:09 GMT","etag":"\"c9489a-4ada-4900100c32a40-gzip\"","accept-ranges":"bytes","vary":"Accept-Encoding","content-encoding":"gzip","cache-control":"max-age=86400","expires":"Tue, 14 Sep 2010 11:03:45 GMT","content-length":"5359","keep-alive":"timeout=5, max=100","connection":"Keep-Alive","content-type":"text/html"}
    

    Hmmm… did I just get lucky and not get a gzipped response that caused your issues? Do you have a page that reliably causes “strange things to happen” that I could test against? Actually, you might need to define “strane things will happen” 🙂

    As a hack, you could get your proxy to change the accept-encoding header so that apache will never return a compressed response. Adding the following to your apache request will force apache to return uncompressed responses:

    req.headers['accept-encoding'] = '*;q=1,gzip=0';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I worte a little Web Proxy program that uses a TcpListener, which listen on
I created a little web spider in Python which I'm using to collect URLs.
I've created a little script for displaying a calendar but the month is 1
Got a strange problem created a little stored proc which need to execute a
i've created a little activeX dll under vb6 which i'm running under classic asp.
I have created a little complex stored procedure on SQL Server 2008 R2 and
I've created a little wpf test application which renders some random rectangles every 30
I have created a little robot like the Karel robot ( Wikipedia ) which
I have a problem with a little .Net web application which uses the Amazon
I have created a little password generation script. I'm curious to what improvements can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.