Giter Club home page Giter Club logo

warp-reverse-proxy's Introduction

Hi ๐Ÿ‘‹

I'm Daniel!, software engineer working at Status

You can follow me at:

๐Ÿง™๐Ÿป Stackoverflow

๐Ÿฆ twitter

github stats Top Langs

warp-reverse-proxy's People

Contributors

beltram avatar danielsanchezq avatar dependabot-preview[bot] avatar dependabot[bot] avatar icewind1991 avatar kpcyrd avatar samuel-rufi avatar zeegomo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

warp-reverse-proxy's Issues

Pass context down

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.

Feature request : websocket support (and altering of host header)

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());

Feature request: option to customize the reqwest client

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.

Can not correct process redirect response

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.

Roadmap

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:

  • Add better documentation
  • Improve testing for corner cases
  • Add usage examples
  • Try to catch the client IP address and attach it to the X-Forwarded-For header
  • Leverage errors (bubble up errors instead of current unwrappings)

Recreating reqwest::Client forces tcp connection to be established each time.

Hello!

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.
image

Consecutive requests use cached dns and handshakes, so one request takes around 160ms.
image

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.
image

Using already existing reqwest::Client cuts time in half, resulting in around 162ms.

I propose maybe use one Client, created lazily with lazy_static.

filter needs to accept routed parameters

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]

Provide way to shut down the client

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

use warp::http

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...

Using with warp::Filter::recover

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(())
}

Feature request: custom client (per request)

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).

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.