felipenoris / hyper-reverse-proxy

A simple reverse proxy for use with Hyper and Tokio
Apache License 2.0
181 stars 63 forks source link

"Unsupported scheme http" when running the example. #38

Closed nicolaspernoud closed 2 years ago

nicolaspernoud commented 2 years ago

Hello,

When running the example with the following dependencies :

[package]
name = "proxy_2"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
hyper-reverse-proxy = { git = "https://github.com/felipenoris/hyper-reverse-proxy", branch = "master" }
hyper = { version = "0.14.18", features = ["full"] }
tokio = { version = "1.18.2", features = ["full"] }
lazy_static = "1.4.0"
hyper-trust-dns = { version = "0.4.2", features = [
  "rustls-http2",
  "dnssec-ring",
  "dns-over-https-rustls",
  "rustls-webpki",
  "https-only"
] }

I get an ̀_error:HyperError(hyper::Error(Connect, Custom { kind: Other, error: "Unsupported scheme http" })) when proxying to a local http service. It seems to be related to hyper-trust-dns client, but removing the feature "https-only" does nothing...

nicolaspernoud commented 2 years ago

I actually managed to get it working with :

lazy_static::lazy_static! {
    static ref  PROXY_CLIENT: ReverseProxy<TrustDnsHttpConnector> = {
        ReverseProxy::new(
            hyper::Client::builder().build::<_, hyper::Body>(TrustDnsResolver::default().into_http_connector()),
        )
    };
}

but it works only with http server proxying to http server. When trying to do tls offloading, the proxy do not converts the http/2 request to an http/1.1 request to the backend. ̀

nicolaspernoud commented 2 years ago

It seems to be possible to convert the version with *Request::version_mut(&mut req) = Version::HTTP_11;. So closing for now. But it would be nice to adapt to the version supported by the backend automatically...