Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tls termination possible? #49

Open
max-frai opened this issue Aug 12, 2024 · 1 comment
Open

tls termination possible? #49

max-frai opened this issue Aug 12, 2024 · 1 comment

Comments

@max-frai
Copy link

Hello, I have the following structure:

haproxy -> backend node -> http-mitm-proxy

Ideally, I need to read response and headers both on http-mitm-proxy backend node and inside haproxy.
For now, I can do this only on http-mitm-proxy side, but not on haproxy. I tried tls termination on haproxy side, but the problem was with tls handshake to backend server (mitm proxy).

So probably it's possible on http-mitm-proxy side to drop tls and return pure http?

@hatoo
Copy link
Owner

hatoo commented Aug 13, 2024

Sorry, your requirement is unclear to me and I've never heard of the term 'tls termination' before.

But I guess you want http-mitm-proxy to work like the yellow area of this image
https://upload.wikimedia.org/wikipedia/commons/thumb/3/34/SSL_termination_proxy.svg/512px-SSL_termination_proxy.svg.png

You need to create a proxy like

    let server = proxy
        .bind(("127.0.0.1", 3003), move |_client_addr, req| {
            let client = client.clone();
            async move {
                let uri = req.uri().clone();

                // Modify Request schema to HTTP

                let (mut parts, body) = req.into_parts();

                let mut url_parts = parts.uri.into_parts();
                url_parts.scheme = Some(uri::Scheme::HTTP);
                parts.uri = Uri::from_parts(url_parts).unwrap();

                let req = Request::from_parts(parts, body);

                // Do HTTP request
                let (res, _upgrade) = client.send_request(req).await?;

                println!("{} -> {}", uri, res.status());

                // You can modify response here

                Ok::<_, http_mitm_proxy::default_client::Error>(res)
            }
        })
        .await
        .unwrap();

This proxy is looked https server from client and do HTTP request to target server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants