codekitchen / dinghy-http-proxy

the http proxy container that dinghy uses
MIT License
125 stars 43 forks source link

Support tcp proxy #22

Closed timneutkens closed 7 years ago

timneutkens commented 7 years ago

Might be interesting to implement https://www.nginx.com/resources/admin-guide/tcp-load-balancing/

codekitchen commented 7 years ago

Since nginx would have to listen on a separate TCP port for each container it is proxying to, we'd have to expose each new port to the host using some mechanism. I'm not sure this would be any easier than just exposing the port in that container directly. Or are you looking to actually do load balancing between multiple instances of a back-end container in dev? That might be interesting, we'd have to think about how to best expose configuration for it.

timneutkens commented 7 years ago

The particular use case I was thinking of was this issue we're having:

We run php environments with mysql, every project has its own mysql container We bind port 3306:3306, so it's impossible to run multiple projects side by side at the moment. I actually like the practice of having the mysql container seperated, it's just hard to use tools like sequel pro without binding the port.

codekitchen commented 7 years ago

We're in a similar boat, we use a separate db container for each project because each project has its own self-contained docker-compose setup.

However, what I meant was that the nginx TCP load balancing has to listen on a separate port for each backend service, since generic TCP doesn't have any functionality like the HTTP Host: header to determine which backend to communicate with. It seems easier to configure each mysql container to bind their port 3306 as a different port, since that's what the proxy would have to do as well -- and then the proxy would also need some way to get the user information on the proxy->backend port mapping.