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

Example to modify response from server #2

Open
roman opened this issue Jun 12, 2013 · 13 comments
Open

Example to modify response from server #2

roman opened this issue Jun 12, 2013 · 13 comments

Comments

@roman
Copy link

roman commented Jun 12, 2013

Hello,

This is more a question rather than an issue/feature. Is there anyway to modify the response from the server in the proxy? I want to add extra script tags to the body.

I'm reading the code, but I can't find any clear entry hooks to do this. Any guidance is highly appreciated.

Cheers.

@erikd
Copy link
Owner

erikd commented Jun 12, 2013

Currently http-proxy does not compile or work correctly with the current versions of the Conduit library.

Once that is fixed it should be possible to do this.

@vincentbernat
Copy link

Hey!

Any news on this one?

Thanks.

@erikd
Copy link
Owner

erikd commented Mar 7, 2015

Sorry, been busy, but actually working on it this weekend.

@erikd
Copy link
Owner

erikd commented Aug 8, 2015

Just curious, what is it you want to modify, the response headers? The body? Both?

@erikd
Copy link
Owner

erikd commented Aug 8, 2015

BTW, the version here in GIt actually works (see https://travis-ci.org/erikd/http-proxy ) if you want to play with it.

@aculnaig
Copy link

aculnaig commented Mar 14, 2019

Hi, thanks a lot for this library.

I can't find the code that lets modify the response.

Has the feature been implemented ?

aculnaig

@erikd
Copy link
Owner

erikd commented Apr 6, 2019

Currently it is not possible to modify the response. It would be relatively easy to do this for HTTP, but not at all easy for HTTPS because for HTTPS connections the proxy simply acts as a transparent two way transport of encrypted bytes between the client and the server. The proxy could theoretically decode this encrypted stream, but not be able to modify them and then re-encrypt them (because the proxy does not have access to the private encryption key the server uses to perform encryption).

In order to decode and/or modify either the request or the response, would require the implementation of what is called a MITM (man-in-the-middle) feature. In this mode, the proxy generates its own SSL certificate and uses this SSL certificate to the client (which must manually accept it). The proxy then gets the request from the client, passes it upstream, retrieves the response and decodes it (where it could be modified), then re-encrypts it using its own SSL key. I am interested in doing this, i just have no idea when I may get it completed.

@juturnas
Copy link

I have some time this week that I would like to spend on a MITM feature. Libraries that I've used in other languages handle this by either 1) generating a CA cert or 2) accepting one as configuration, and minting + caching a short-lived certificate for each host name they proxy a request to. @erikd do you have an idea of how you'd like to see this implemented?

@juturnas
Copy link

I have a working proof of concept for this now, but it is very rough (I had to hack my way around my lack of conduit knowledge). I may clean it up soon and can open a PR if there is interest, otherwise feel free to ping me for code.

@erikd
Copy link
Owner

erikd commented Apr 19, 2019

I too have started thinking about this, but I am currently traveling for work. Let me get back to you on this.

I would also be happy to look at any code you have.

@erikd
Copy link
Owner

erikd commented Apr 20, 2019

I have been messing with this a bit and I think the best way to do it is to add a separate module for the MITM functionality. Obviously, whatever can be shared should be.

@erikd
Copy link
Owner

erikd commented Apr 21, 2019

@juturnas I would be really interested in seeing what you have. There are a number of ways of doing this and two that I have tried so far are problematic in one way or another.

@YellowOnion
Copy link

Any updates on this? Unless I'm misunderstanding, you can't easily implement a caching system currently, not interested in MITM SSL connection.

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

6 participants