Comments (4)
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.
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.
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.
Fixed in 0.3.1:
npm install [email protected]
from node-http-proxy.
Related Issues (20)
- Proxy failed
- Get the response data from target server with express
- With "toProxy" the url recieved by the proxy server has a "/" prefix HOT 3
- Using cert auth results in `SSL alert number 46` HOT 1
- Proper way to handle error HOT 2
- Content-type Header Not Handled Correctly for JSON and Form Data with Charset Information
- Add blacklist headers to protect against DoS attack
- Resolving Digest Auth challenge in middleware using events? HOT 1
- Reverse Proxy Randomly Hangs for Larger Data When Running With Bun Runtime HOT 1
- Proxy don't work when switch target URL to object
- RSSI List
- UNMAINTAINED WITH SECURITY ISSUES
- How to forwarding a request when the proxy not found . HOT 1
- Single use proxy in multi-tenant application
- How to detect which client is receiving the package?
- Please fix version of Library "follow-redirects" to eliminate CVE-2023-26159 issue HOT 3
- Contact point or SECURITY.txt file
- Is the repo still developing actively ? HOT 1
- node-http-proxy HOT 1
- Node 18 will close proxied websocket connections after ~60 seconds
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-http-proxy.