nginx-proxy icon indicating copy to clipboard operation
nginx-proxy copied to clipboard

Support for stream module

Open sjawhar opened this issue 8 years ago • 5 comments

I wanted to float an idea: support for streaming connections. I put together a quick proof of concept on the stream branch of this fork. Run docker-compose -f docker-compose-separate-containers.yml up -d --build to see connections proxied to both the whoami service and a mongo service. You can grab a mongo admin UI and connect to it using mongo.local:27017.

So, what do people think? Is there a valuable use case for this?

Downsides:

  • You can't have different VIRTUAL_HOSTS listening on the same port, since there's no hostname resolution like with HTTP.

Work left:

  • Get it working when docker-gen and nginx are running in the same container
  • Block http access over the streaming port
  • Finish stream.tmpl
  • Tests

sjawhar avatar Apr 15 '17 19:04 sjawhar

Would this allow me to run OpenVPN behind nginx-proxy?

clobber88 avatar Aug 19 '17 02:08 clobber88

I'm very interested in this functionality, but I think this would require deviating from the official nginx docker image. They don't seem to provide the stream modules from the official images.

aackerman avatar Sep 03 '17 00:09 aackerman

Yes, it requires building on the official nginx image. You can see the Dockerfile I put together to do that here: https://github.com/sjawhar/nginx-proxy/blob/stream/Dockerfile.nginx

My main concern, as the person who opened this issue and made the fork, is that I'm not sure it's even a good idea to start with. Maybe it's better to just use HAProxy or something.

Also, since you can't have different VIRTUAL_HOSTS on the same port... I'm struggling to remember why I started this. :)

sjawhar avatar Sep 03 '17 04:09 sjawhar

I would find this useful. I'm using the Let's Encrypt companion container to manage SSL certificates for a bunch of HTTP hosts. Now I would like to put my MQTT server behind the proxy and have its certificate renewed automatically.

cgraefe avatar Nov 14 '18 08:11 cgraefe

i think, can split nginx.tmpl in two files: upstream.tmpl --> upstream.conf server.tmpl --> default.conf

then, can include upstream.conf in http and stream

lloydzhou avatar Apr 08 '25 03:04 lloydzhou