-
Notifications
You must be signed in to change notification settings - Fork 241
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
Upstream proxy feature #17
Comments
@l5h5t7 I am not sure if I completely understand your use-case. Is it: If I did not understand you correctly, please describe setup in more details, including what exactly both proxy servers will be doing. |
@sergeyfrolov all this can be done by proxy chain support. |
What @jim3ma said is exactly what I'm talking about. |
@sergeyfrolov and I have talked about this a little, but I have been too busy with other things to run any experiments myself. It might very well be possible without too much trouble, but we'd have to see if forwardproxy can be configured in conjunction with proxy; including perhaps moving the forwardproxy directive higher in the chain than proxy, if necessary. If someone wants to look at this, it'd be good to start by setting up a |
To clarify a bit, there's potentially following solution. Assuming that
...we can get forwardproxy things like auth and probe resistance, then just push the traffic down the middleware chain |
Can a subdirective to forwardproxy be set to tell it that yes, we are using |
Yes, we can totally do it this way. Say we name the option
I think it's fine to use some option explicitly, it also makes sure we don't inadvertently affect other uncommon setups. |
@jim3ma @l5h5t7 |
@sergeyfrolov I think what @l5h5t7 need is a proxy chain, the traffic must forward by forwardproxy to upstream proxy |
@jim3ma |
@sergeyfrolov @mholt |
@jim3ma |
I'd rather have smaller, independent middlewares that work together rather than making a big middleware that does everything; perhaps there is a (simple) change to proxy that could work. Or, better yet, what if it was a straight-up TCP proxy? Caddy has one of those. 😎 https://caddyserver.com/docs/net |
Implementing the upstream proxy requires to connect a proxy server such as socks5, http/https proxy. There are many proxy types:
And we can also enable some optimizes like QUIC with proxy. |
If we put simple net plugin after forwardproxy, that should cover http proxy upstreaming. |
Out of curiosity, how is the Caddy-as-client proxying being conducted? My understanding is that Go's built-in capacity for HTTP proxies doesn't support an arbitrary bytestream for HTTP CONNECT but is instead closely tied to an individual request. E.g. if a go client opens an HTTPS connection to a remote server over a proxy, you can do:
but not:
It seems like the latter is what you'd need for this |
@mholt It's about the protocol. |
Okay. I'm still not sure I follow -- the iptables approach doesn't care about protocol. It should just forward the bytes along as if it wasn't even there. But what is the goal again? The OP says:
So it looks like the goal is indirection. If one proxy is inaccessible, and you have to proxy through a proxy to get to another proxy, why not just configure that "middle" proxy to be "the" (only) proxy? Like, why do you need two? You'll have to forgive me, I don't personally have much experience with needing to use proxies that get blocked, but I do want to understand this thoroughly as possible, especially since I'm speaking about it at Internet Freedom Festival in less than a month! |
@mholt I think the most common scenario which needs this feature is surfing internet under China GFW. In China, if you want to access Google, Facebook and Twitter, you need other VPN or proxy. The upstream feature sounds like squids parent proxy or nghttp2 proxy with backend. The squid ACL and parent proxy support is very powerful, HTTP/2 with TLS is easy with caddy. If we can chain these two features in caddy, it would be great. Currently, nghttp2 + squid or cow can archive the upstream feature without caddy. Compared to proxy method, you can set iptables up in router or local machine, but it is a little difficult to set up for most people, proxy method is much easier and everyone can use it in browser. |
One case: I run a caddy with forwardproxy in my mac for debugging some web site or ip such as google.com in China mainland. While my mac cannot connect with google.com due to GFW. I need upstream proxy to enable connective with google.com Another case: data Link optimization
|
some additional info about @billryan 's cow mode. In the later mode, we enjoy full http/2 support, you'll find very few connections to caddy server. (Can test with netstat -an) I hope the new feature can also have full http/2 support. |
I use Caddy as a forward proxy specifically for the http/2 support. Also, squid and others tend to spawn separate processes for each request. This is untenable in today's https environment with some sites requiring connections to 3-5 other sites just to show a page. Performance requires a big beefy box, but with Caddy, I'm able to run the same amount of connections on a much smaller platform. As for the need for an upstream directive, a considerable number of corporate environments run a proxy for filtering sites, and do not allow outgoing connections from anything other than the proxy. With an upstream in this plugin this would allow testing and debugging behind any proxy. |
Okay, I can see why this would be useful. I don't have time to do it, unfortunately. Maybe somebody else does. |
I have an existing pr in for a different function of forwardproxy, but @jim3ma was very close to having this solved. Once I clear that pr, I can fork his changes and integrate them. |
Alright. It seems like both #22 and #26 do the same thing, but #26 also supports multiple upstream IPs. I like #22 more than #26, since it adds ~6 times less lines of code, and is, as a result, cleaner. We certainly don't aim to be a cutting edge squid replacement, which may lag behind on http/2 support, but it's on their roadmap. That being said, we can add multiple upstream IPs, as long as the code is small and easily testable (I'd like to have at least a very simple sanity check for everything). @jeddytier4 is there a compelling reason to have so many policies? It would be substantially neater if we had just one. Do you have any suggestions on which policy would be best? Hashing IPs? |
@sergeyfrolov #26 changes the outgoing IP address on the host, instead of letting the local system choose the best route based on the target IP, it does not allow for an upstream proxy request. I will trim the policies down to ip_hash and random, as these are the only 2 that I have seen any benefit from using. Any other suggestions for cutting the code back would be greatly appreciated. |
My bad, got confused and thought #26 is your fork of #22, and didn't look too much into it. I checked it out by now, and left some comments: let's continue discussion of #26 in PR. |
We are trying to make decision about which schemes are we going to support. cc: @l5h5t7 @jim3ma @billryan @bash99 @jeddytier4 |
http traffic is insecure and should not be used as upstream proxy through public network, while for private network or local server, it is a nice feature to support insecure scheme such as http/socks. For my use case,
Currently I can use caddy(compiled with jim3ma's fork) as https(HTTP/2 and HTTP 1.1) proxy to use in public network and forward proxy request to upstream proxy(in the same server with caddy). If forwardproxy supports https upstream only, then we have to secure http proxy with TLS first. Without caddy, we have to setup TLS and secure related settings which caddy does this really well. |
@billryan I agree with your point on localhost upstreaming: it allows insecure schemes. |
Implemented in #27. |
Any plan to upstream proxy support?
Sometimes we want access another proxy to connect some host, but it's not secure and it might be blocked, use a secure & hidden proxy to connect is useful.
The text was updated successfully, but these errors were encountered: