blaze icon indicating copy to clipboard operation
blaze copied to clipboard

blaze-client doesn't support proxy settings

Open elyast opened this issue 9 years ago • 12 comments

On behalf of Bryce Anderson, moving issue with http proxy to http4s repo

Original issue: http4s/blaze#14

I'm not practiced in the art of http proxy, so if any of the below procedure is wrong, let me know. I've never implemented it, just done a little reading (prompted by your issue).

We need to add the ability to configure a proxy here and here. Next, we need the clients (pooled and simple) to know to rewrite the request line to include the whole url. This will need to be done in Http1ClientStage. That means it also needs to know about the proxy (if there is one). It gets initialized from Http1Support which means you must pass the proxy config down the line. Could you also please link some appropriate RFC's/whatever else you find relevant in the issue?

I haven't though much about how https will effect all of this, and probably should read about it. At any rate, do you want to close this issue, open an appropriate one in http4s/http4s? Please copy the discourse above and reference this issue when you do. I'm happy to help guide you through the process, but know I'm not an expert in proxy so I hope to learn something in the process as well.

elyast avatar Apr 16 '15 01:04 elyast

As far as I checked the code of https://github.com/AsyncHttpClient/async-http-client in case of http protocol following things needs to be done:

  • rewrite request line (to include original full address of http endpoint)
  • rewrite/add authentication header if proxy requires this

In case of https protocol is actually more tricky, because http client needs to do more work:

  • first it needs to issue HTTP CONNECT to proxy and then proceed with the request (plus above things), it's probably due to ssl termination issues

I will try to find some RFC to be sure how the protocol look like, in case of http proxy since its also my first time to implement one.

elyast avatar Apr 16 '15 01:04 elyast

:+1:
I just got bitten by this. I naively thought that adding -Dhttp.proxyHost= would magically make things work ..

Have you started any implementation of this somewhere?

suls avatar Aug 10 '15 02:08 suls

Sorry didn't have time to work on this

elyast avatar Aug 10 '15 04:08 elyast

We've gotten a couple requests about this recently. Putting this on the map for 0.16.

rossabaker avatar Mar 01 '17 04:03 rossabaker

May I ask the status of this issue at the moment? Is pull request http4s/http4s#1182 heading down the right path? It looks like a lot of work was done on it!

cjwebb avatar Oct 27 '17 12:10 cjwebb

I think it mostly was on the right path, and I still want to see this finished. We just had other priorities. I'd be happy to support someone if they want to pick this up and run with it.

rossabaker avatar Oct 27 '17 12:10 rossabaker

Is there any way known workaround?

stefanobaghino avatar Nov 14 '17 15:11 stefanobaghino

@stefanobaghino async-http-client supports proxies, and http4s-async-http-client has the same interface as http4s-blaze-client.

rossabaker avatar Nov 14 '17 16:11 rossabaker

@rossabaker Thanks for the help!

stefanobaghino avatar Nov 15 '17 09:11 stefanobaghino

We still need this for blaze. In the meantime, @dwalend has a gist for async-http-client.

rossabaker avatar Mar 26 '18 17:03 rossabaker

Hi, I switched to AsyncHttpClient and the proxy is working.

@dwalend Thanks.

I still think it should be an issue on Blaze also, even if the builder is changed on http4s side the BlazeClient doesn't support something so simple like a proxy.

vjroby avatar Mar 12 '19 15:03 vjroby

Due to a bug at the netty/asynch-http-client boundary that showed up under load, we switched to https://jdk-http-client.http4s.org/stable/ to get the full proxy features. It's not as nice as having it in ember, but no instability problems.

dwalend avatar Jun 21 '21 16:06 dwalend