I'm Daniel!, software engineer working at Status
You can follow me at:
๐ง๐ป Stackoverflow
๐ฆ twitter
Fully composable warp filter that can be used as a reverse proxy.
Home Page: https://github.com/danielSanchezQ/warp-reverse-proxy
License: MIT License
I'm Daniel!, software engineer working at Status
You can follow me at:
๐ง๐ป Stackoverflow
๐ฆ twitter
Hello,
I think it would be very useful to include a generic parameter in the proxy_to_and_forward_response
to pass a shared context down the pipeline.
My case is that I want to log the bytes moved to backends (this is ok) but also from them (this is not because I can pass info through proxy_to_and_forward_response
).
I can make a PR to help you.
Hello,
Thanks for this useful work.
It would be nice if this reverse proxy allowed proxying of websockets, as Go proxy does.
I tried proxying "websocketstest.com" through this proxy and it does not work.
Also, to do this proxying (as well with www.example.com), I needed to alter the host header to match the host of the proxy target in the filtered_data_to_request
function. It could be nice if it was done by default, to allow proxying servers with virtual hosts.
Thanks and best regards.
PS : the (dirty) way I replaced the host header below :
let host = proxy_address
.replace("https://", "")
.replace("http://", "")
.replace("/", "");
let proxy_uri = if let Some(params) = params {
format!("{}?{}", proxy_address, params)
} else {
proxy_address
};
let mut headers = remove_hop_headers(&headers);
headers.insert("host", host.parse().unwrap());
The warp-reverse-proxy library uses reqwest behind the scenes but it is currently not possible to customize the reqwest client configuration.
There are some use cases where client configs other than the default are needed, so it would be good provide this functionality.
Hello
The proxy_to_and_forward_response
method seems can not process 30X response from backend.
It will follow the redirect url and return the content with 200 status code.
I have tried to set
let reqwest_client = ReqwestClient::builder().redirect(RedirectPolicy::none()).build().unwrap();
PROXY_CLIENT.set(reqwest_client).expect("client is set");
But the response code is still 200 without Location
header info.
It is published the first version of the library in crates.io, it still can be improved and I will be working on the next features/fixes:
X-Forwarded-For
headerHello!
I have remote server on the other side of the globe. Simple (first) postman request to this server takes around 600ms to complete, including dns lookup and tcp handshakes.
Consecutive requests use cached dns and handshakes, so one request takes around 160ms.
Though, when i send identical request to localhost reverse proxy each request takes around 330ms. I guess establishing new connection each request takes its toll.
Using already existing reqwest::Client
cuts time in half, resulting in around 162ms.
I propose maybe use one Client
, created lazily with lazy_static
.
I want to build a reverse proxy that determines the proxy address dynamically for each connection request, rather than using a hard-coded parameter that remains fixed for all invocations.
I struggled long and hard trying to make work / re-build your reverse_proxy_filter function to be async and accept routed parameters, but sadly my knowledge of warp isn't up to it.
So, my suggestion is, to be generally useful, your filter needs to accept routed parameters [or provide an example that shows warp newbies like me how to configure a route to accept routed parameters]
Currently, since the client is a part of a static once cell, there is no way to control when the client is shutdown / dropped. A way to control when the client is dropped would be useful
Just a small suggestion:
Reduce the crate dependencies by using warp's own exported http library dependency, rather than (re)introducing the http library.
i.e. use warp::http::{HeaderMap, HeaderValue, Method, Response, status::StatusCode}; .. etc...
Would it be possible to make the errors:Error enum public so that it can be used in a warp::Filter::recover implementation?
Currently it is not possible to do something like:
use std::convert::Infallible;
use warp::{Rejection, Reply};
use warp_reverse_proxy::errors::Error;
pub(crate) async fn recover(rejection: Rejection) -> Result<impl Reply, Infallible> {
if rejection.is_not_found() {
//
} else if let Some(err) = err.find::<Error> {
// Handle reverse proxy errors
}
else {
//
}
Ok(())
}
Hi,
First of all: Great work! I want to modify the body (and the headers) of a post request before the request is forwarded. Any hints?
Best regards
Gregor
Publish a new version with the new TLS feature: #20
hi, a nice feature to have would be a filter, that lets you set a custom client per request. My use case for that would be disabling the tls verification, but only to some backends (self signed certs).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.