GithubHelp home page GithubHelp logo

Comments (4)

Marak avatar Marak commented on May 13, 2024

Hello! I'm a little confused about this.

The current implementation should pass the original request object which will contain a "url" property.

Can you explain how this implementation doesn't achieve the functionality you want? Are you talking about parking a router in-front of the reverse proxy so you can dynamically route requests?

Could you possibly write a test case or perhaps pseudo code what the api for this would look like?

Thanks!

from node-http-proxy.

dready92 avatar dready92 commented on May 13, 2024

You're right, certainly it wasn't a good day yesterday ! Anyway I was thinking to a sort of a thin "router" layer on top of that to automate a little bit the process.

As an example : if you want to reverse proxy http://www.server.com/foo to http://server1.local/foo , instead of having to :

  • modify the URL property of the request
  • check for the response headers of server1.local and rewrite the "Redirect" header if any
  • and perhaps some other things I don't think of now

just have something to predefine route, a bit of code to illustrate :

var httpProxy = require('http-proxy').httpProxy;
httpProxy.setRoute( "/foo", { 
    "destination": "http://server1.local/foo"
});
http.createServer(function (req, res){
    var proxy = new httpProxy;
    if ( proxy.route(req,res) ) {
        // proxy handled the request because one of the pre-set routes match
        return ;
    }
    // no route were defined by setRoute
    }
}).listen(8000);

That way you provide features for common reverse-proxying needs, ex cookie rewriting, load-balancing, encoding ...

from node-http-proxy.

Marak avatar Marak commented on May 13, 2024

Okay, that makes a lot of sense.

The codebase we extracted this from does have a router and (somewhat of a) load balancer. I didn't want to clutter http-proxy api, but you do have a valid point. While having the raw access to httpProxy.proxyRequest() is great, most people will want the more advanced functionality you mentioned.

I could write a new router for this, or use a pre-existing one. I'm going to think on this for a few days and determine the best plan of attack. It's important to me that we keep the api clean, but I think there is a good solution to be had here. Hopefully I'll have a patch by next week.

In the meantime, do you think you could elaborate on the functionality you mentioned of cookie rewriting and encoding?

Thanks a lot for your feedback, it's much appreciated.

from node-http-proxy.

indexzero avatar indexzero commented on May 13, 2024

Fixed in 0.3.1:

npm install [email protected]

from node-http-proxy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.