-
Notifications
You must be signed in to change notification settings - Fork 505
Proxy http requests to external proxy for internet access #1838
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
Comments
Thanks for filing this, @krjensen! |
Let me know if you need more information from me. |
We have this same exact use case. Finagle supports this ( see here ), it just needs to be 'exposed'/'lifted' to linkerd http level configs. Perhaps as static client config options to allow per router config. I can offer some time to look at this, however, my scala is rather rusty - any pointers/starting locations would be very much appreciated. |
Maybe @adleong or @dadjeibaah can share some pointers. |
If my understanding is correct, there are two different scenarios being discussed in this issue. Let me discuss them individually, and please correct me if I have misunderstood. @krjensen is asking about sending all egress traffic through an HTTP proxy (squid). This should be easy to do by adding a fallback rule to the dtab which sends requests directly to the HTTP proxy. Something like:
Since later dtabs rules have higher priority, this dtab rule should be added to the start of the dtab. This will effectively act as a fallback. If a request is made to Linkerd and Linkerd cannot resolve it through service discovery, it will fallback to sending it to the HTTP proxy. @sean-brandt on the other hand seems to be asking about sending traffic through a SOCKS proxy. This is more complex because Linkerd needs to be made aware that it is talking to a SOCKS proxy and use the SOCKS protocol. As you say, Finagle does have support for this. The way I would imagine this working is by adding the ability to specify a SOCKS proxy on a Linkerd client configuration. eg something like:
If this is something that you're interested in, @sean-brandt, would you mind opening a new issue specifically around SOCKS support? |
No, I'm looking to configure linkerd to, on a per 'service' basis use an http 'forward proxy' to reach external services. This may be either over http, or https, so the protocol requires supporting http proxy specific communication. Generally I'm looking to support this:
No need, nor desire, for SOCKS at all on my end. |
@sean-brandt in that case, you should be able to take care of the routing entirely in your dtab:
Will route requests for |
@adleong Ok. How, then, is linkerd supposed to know where to tell the proxy to go to? The 'proxy' in this case is a forward proxy ( squid, or similar ) and it is expecting requests to it to follow the http proxy protocol. Basically requests would require that GET/HEAD/.. use the fully qualified host/url and the Host header be set to the destination. Where would I configure that |
Additionally - as I noted above, Finagle supports this. It really just needs to be exposed somewhere/how in the config.
|
Linkerd forwards the Host header unchanged which means that it needs to be set to the desired final destination by the application that is sending the request to Linkerd. Something like this: App sends request to Linkerd:
Linkerd routes Proxy sends the request to foobar.nowhere.com. Does that make sense? |
That makes sense, at least in the plaintext case - I think. :) I'll put together a test, since I'm not certain that it will work with the TLS case ( where the ultimate target service is https ) and a proxy 'tunnel' is required using the CONNECT method. |
Any progress on this? |
Good question. Putting aside SOCKS proxying and CONNECT tunneling for the moment, I think this issue is specifically about configuring Linkerd's routing rules to use an HTTP proxy. @sean-brandt and @krjensen: do my explanations here make sense? Can we close this issue? |
TLS doesn't work via the routes above, or at least I wasn't able to get it to do so. It's the switch to the CONNECT method and related work that's the issue. There is code in Finagle to support this - unfortunately, however I lack the time and familiarity to be able to help out much more than that. |
Hmm, additionally - a 'test' should be easy enough to replicate self contained, presuming a containerized environment.
|
Ah, yes, this is expected because Linkerd does not support creating tunnels with the CONNECT method. I've filed #1982 to track that separately. |
Absent CONNECT support, I've got no opinion one way or the other on this particular issue. #1982 covers my use-case/concern, I believe. |
Any reason why this was closed? |
Why did you close this issue. I still think it's 100% relevant and a feature we really need. |
@adleong - even for the HTTP case, the suggested dtab doesn't work. We're also using Squid proxy server as Sean describe. Basically I needs to follow http proxy protocol for Squid to successfully process the request. |
Hi, I have a similar issue. I used Squid proxy and Docker containers. Squid itself works as expected. But if requests are routed via Linkerd with this rule
|
Hi @DudnykOleksandr! I think the problem has to do with the way that proxies interact. Linkerd acts like a transparent proxy which means that when clients modify a request to make a proxy request by making the URI absolute, Linkerd undoes that change by dropping the scheme and making the request back into a normal request. That behavior was added to Linkerd in this PR. However, squid expects to be treated as a proxy and expects proxy requests with absolute URIs. I haven't used squid, personally, but it looks like this behavior can be changed by changing the squid to intercept mode:
I believe that in intercept mode, squid no longer requires requests to have absolute URIs. |
@adleong thank you for clarifying this behavior. |
Issue Type:
We are running a Linkerd-to-Linkerd setup where we use
http_proxy
to route HTTP traffic to Linkerd, but in our infrastructure internet access is only provided using a proxy server. We need to be able to tell Linkerd to proxy internet traffic to another proxy server.Here is the Linkerd config we use today:
We have tried to use the
io.buoyant.rinet
but that only gives us the feature to make Linkerd make http requests to external resources, but not to a proxy. We could route internet traffic directly to the Internet proxy, but then we loos all the features of Linkerd and we need to implement that in all our services.We are only using http(s) so we do only need to talk to an http proxy(in our case a squid).
Our end gold would be a flow looking like this:
[service] -> [Linkerd] -> [InternetProxy] -> (Internet)
Or if multiple connected services are in play:
[service] -> [Linkerd] -> [Linkerd] -> [service] -> [Linkerd] -> [InternetProxy] -> (Internet)
Environment:
The text was updated successfully, but these errors were encountered: