-
Notifications
You must be signed in to change notification settings - Fork 617
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
TCP proxying support #1
Comments
Transparent TCP proxy support was on my radar at some point but so far I didn't have the use case for it. I want to enhance a couple of other things first so this is not high on my prio list ATM. Leaving this open as enhancement |
Sounds good. Just remember, when you get around to it, that SNI is a must as it's really the only way to route when doing TCP routing (since mapping ports is just awful)! |
+1 Transparent TCP is currently a gaping hole that no one has filled. edit: To clarify, a transparent TCP proxy that can work with a Consul/Etcd/Mesos/etc natively that can do connection draining. |
@rvm2015 I assume you mean, "within Fabio"? Other services are capable of doing transparent TCP proxying,and have for a long time. |
@rvm2015 What is your use case? |
If Fabio had the ability to do TCP as well as HTTP I'd have a reason to put in the work to extend the backend support to include Mesos/Maratho. I'd then be able to replace both Traefik and HAProxy/Mesos-DNS with a single service and greatly simplify my stack. |
@rvm2015 Fabio is an FE-BE router which routes incoming traffic to different BE services based on information in the protocol (i.e. host and/or path from the HTTP request). I get the SNI use case for SSL traffic since I can get the host information and use that for routing information but how would I route an arbitrary incoming TCP stream to a BE service that can handle it? Based on ports? Which protocols are you using where you need raw TCP traffic? |
I think I have a couple of use cases for TCP routing now and the proxy itself is pretty simple. I just need to update the config language and dynamic listener support. First version may not support SNI though but I'm still looking into this. |
👍 |
Transparent TCP proxy is useful when deploying such services as IM server, RPC services within docker container cloud, given this feature enabled, fabio could be a replacement for HAProxy totally for cloud environment. |
Don't want to be one of those "me too" people but did anyone manage to get anywhere with transparent TCP proxying (with or without SNI)? @magiconair I know above you said you were looking at this? Is there any WIP we can possibly help commit to if not finished? Else I might take a stab at this, as this is currently the one thing we're missing as we have lots of arbitrary TCP ports which would benefit hugely from fabio / only work through fabio. Thanks in advance! |
@JonathanBennett The TCP proxy itself is not difficult and I think I have that ready somewhere. Main issue is how to configure the listeners and that they need to start and shutdown automatically which is different from the statically configured HTTP listeners. That also isn't hard but $dayjob and $kids take most of my energy right now. I'm going to focus on the API for the multiple registries since this is a small change but has lots of potential. Then I'll work on the config change which will enable the strip prefix and weight parameter and also offer the tcp syntax. Then it isn't far from the dynamic listeners. I have some code lying around for that as well but it probably won't merge anymore. If you want to help you could pick up one of these things. Let me know if you are interested and we can try to figure something out. |
Hi, is anyone working on this one? |
@mterron It is on my list but I am working on other things right now. What is your use case? |
@magiconair if fabio could do straight TCP+SNI (+PROXY proto?) load balancing I wouldn't need to deploy certs to fabio. This will solve a transitive trust issue where you have to trust fabio with private keys for a service itself doesn't provide. It is much easier to only deploy certs to the server/container/vm that need access to the plain text and keep an end-to-end encrypted connection, especially in environments where security is important. |
To speak in parallel with some of the mentions earlier, I would find sni passthrough extremely desirable. I know a lot of people, including myself, like to keep encryption end-to-end and store their key/cert with the application itself, instead of maintaining it at the LB. As a previous user said, most solutions out there which implement dynamic backends making them more juicy for micro-service deployment don't support this (fabio, traefik, hipache, etc), whilst the solutions which support this don't support dynamic backends (i.e. haproxy, nginx, caddy). Fabio could be one of the first All-In-One solutions that is flexible enough to do this! |
@InAnimaTe yes :) |
This patch adds support for configuring a listener to provide a passthrough TCP proxy for TLS connections and use the SNI server extension in the ClientHello message for routing. Targets need to register their prefix as 'host/' for now. This implementation is functional but not production ready since it does not yet set proper timeouts on connections. This will be fixed before the change is merged.
@InAnimaTe, @mterron, @jefferai et. al. here you go. This patch implements TCP passthrough support for TLS connections and uses the SNI header for routing providing end-to-end encryption with dynamic routing! This is working but needs testing. Please hit on it and find out where it breaks. I need to think a bit more about timeouts and edge cases. Here is how you can test this:
This will configure a listener on port The
You'll get some Then run
and test with
You should get
Or with curl (make sure you use the homebrew version on OSX):
|
You sir are a God among Men. I have a few services I plan to test this with sometime this week. Really glad you put forth the effort and time to get this initial version committed. Appreciate it! |
@InAnimaTe any update? |
@nugend What's your use case? |
Internal app using a custom connection oriented protocol. A number of client teams that don't really have the ability to be aware of our multiple instances. |
Hey @magiconair , I can't seem to get the ELB PROXY and I.e. In the https case, my curl just hangs, I'm not sure where it's hanging. Meanwhile fabio is spitting out In the tcp case, I get |
@holtwilkins I'll have a look |
@holtwilkins the PROXY protocol is only on the HTTP listener right now which will break the TCP+SNI listener as it will not be able to parse the ClientHello. I'll add that and put a patch on a branch. Could you test that? |
I sure can, just point me at the branch when it's ready! |
The TCP+SNI proxy fails when used behind an AWS gateway with PROXY protocol enabled since it will not properly decode the ClientHello from the TLS handshake. Adding the proxyproto listener support to the TCP listener should fix this as it should properly strip the PROXY header from the bytestream.
@holtwilkins I think that should do it. I'm working on making the TCP+SNI proxy more testable anyway and I'll add that to the test cases. However, that change isn't ready yet. |
@holtwilkins In case you didn't see the |
Thanks @magiconair , it worked for me! |
@holtwilkins Excellent. Then I'll merge it and make sure that I have a test for it in the next update. |
Merged this to master and referred to it as #177 |
Generic TCP proxying support is now in the |
I thought you weren't supposed to ever close bug #1 :-D Great job! |
* Add generic TCP proxy support. * Add support for ReadTimeout and WriteTimeout for the TCP and the TCP+SNI proxy. * Add integration tests for the TCP and TCP+SNI proxy. * Update the demo server to provide a TCP server. * Add a tcptest package for generic TCP server testing. Fixes fabiolb#1, fabiolb#178, fabiolb#179
Issue 613 tcp dynamic
This looks super cool. Wanted to send along a feature request that I think will make it even more useful.
At a previous job, we were using haproxy due to its ability to do not only straight TCP proxying, but straight TCP proxying while honoring the SNI header. This allows the TLS connection to be direct between a client and backend server, rather than having a proxy in the middle decrypt traffic and re-encrypt traffic to the backend. This direct connection is needed to avoid transitive trust issues, and can be especially important if you are required to adhere to various industry conformance standards like PCI.
So my feature request is: please allow straight TCP proxying while honoring the SNI header for routing.
The text was updated successfully, but these errors were encountered: