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

using a socks or http proxy #707

Closed
mischief opened this issue Jun 2, 2016 · 12 comments
Closed

using a socks or http proxy #707

mischief opened this issue Jun 2, 2016 · 12 comments

Comments

@mischief
Copy link

mischief commented Jun 2, 2016

how can a socks or http proxy be used with a grpc client?

afaict, it's currently not possible.

it would be great if this was transparent to programs (at least for http proxies) like the default net/http client. in that case, it's simple to make a http proxy to socks bridge.

https://godoc.org/net/http#ProxyFromEnvironment

@mischief
Copy link
Author

cc @milesward

@puellanivis
Copy link

So, I've had to work around haproxy not supporting HTTP/2.0 and requiring that all traffic therefore need be HTTP/1.1 with a Hostname field (which is a fair assertion about HTTP/1.1 traffic, because it's defined to require that header.)

The solution I came up with (which is sickening to admit) is using HTTP/1.1 requests and polling with cookies to hold a connection open, and return a net.Conn implementation on top of that for the accept method of the grpc server.

I mean, this is insane, and dumb, and no one should do it but I needed things to work /now/.

So, yeah, please, no one should have to implement HTTP/2.0 over HTTP/1.1 over TCP/IP. It would be nice if there were a good solution, instead of things like my hack.

@mwitkow
Copy link
Contributor

mwitkow commented Jul 30, 2016

@mischief proxying over HTTP CONNECT can be done using a custom dialer. That's why I wrote https://github.com/mwitkow/go-http-dialer

@mischief
Copy link
Author

@mwitkow sure, it could be. however, if go-grpc simply used ProxyFromEnvironment it would be fixed for all users.

@chandradeepak
Copy link

yeah it would be good if grpc supports it by default

@ejona86
Copy link
Member

ejona86 commented Sep 12, 2016

We are adding HTTP CONNECT support in C core (grpc/grpc#7611) and this is a cross-language feature that would benefit all languages. Thus, we believe we should do it in Java (grpc/grpc-java#2193) and Go as well. C will definitely get it first, but we will be trying to schedule this work in for the other languages.

We are not planning on SOCKS or similar. Those are much larger beasts than simple HTTP CONNECT.

Note that I wouldn't have expected this to be a good solution for haproxy and other server-side proxies, although I guess maybe it could work as a hack. The supported use case is for environments that must connect through a HTTP proxy to access the external world, like many enterprise environments.

@mischief
Copy link
Author

@ejona86 sounds fantastic. my end goal is similar to the enterprise use case, except that i want to run etcd v3 through tor :-) even though tor uses a socks5 proxy natively, i wrote a little program that acts as a http proxy and converts those connections to socks5 proxy requests, so native support in grpc is not strictly necessary - but native support for http proxies in grpc-go is what i want, so all grpc-go programs can benefit from it. ideally, it would be done through ProxyFromEnvironment().

@hsaliak
Copy link

hsaliak commented May 17, 2017

#1095 should solve it. It implements gRFC A1: grpc/proposal#4 which is the feature @ejona86 mentioned.

@hsaliak hsaliak closed this as completed May 17, 2017
@matihost
Copy link

matihost commented Nov 23, 2017

I've just entered this issue because i'm behind socks proxy.

How can I define different proxy or remove using proxy for gRPC client?

I'm looking for a solution in the code itself, not via setting system environments.

@menghanl
Copy link
Contributor

The proxy is now part of the default dialer.
If you want to redefine or remove the proxy, you can override the dialer with a DialOption.

@nscavell
Copy link

nscavell commented Dec 7, 2017

@menghanl am i reading the code correctly, does the proxy not support authentication ? For example setting Proxy-Authorization for an http proxy ?

@menghanl
Copy link
Contributor

menghanl commented Dec 8, 2017

@nscavell Right, authorization is currently not supported. #1446 mentioned the same problem. PR #1447 was filed to fix it, but it was not finished.

We currently don't have cycles for this now. I proposed a solution in this comment #1447 (comment). So if any one has cycles and wants to send a PR, it will be great.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants