codekitchen / dinghy-http-proxy

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

Livereload support [ more generally: ports other than 80 and 433 ] #17

Open dts opened 8 years ago

dts commented 8 years ago

It would be great to add support for additional ports (that speak HTTP-ish). Specifically, I have quite a few projects that all want a "livereload" port. I currently just open them up to the top-level docker host on project-unique ports, but it would be better to add a VIRTUAL_PORT_35736=36736 (or whatever) environment variable, and have dinghy-http-proxy open up an http-ish port at 35736 and proxy that to the appropriate host at 36736.

codekitchen commented 8 years ago

By HTTP-ish do you just mean "speaks HTTP"? The "ish" is throwing me off. :) As long as we're just talking about listening and proxying on dynamically configured HTTP ports, that doesn't sound like it'd be too much work.

dts commented 8 years ago

I say HTTP-ish because websockets aren't really "normal" HTTP in my mind (I haven't read the spec, but my guess is they actually /are/ HTTP in the sense that matters, having an origin: header and looking generally like HTTP).

codekitchen commented 8 years ago

Websockets start out as a HTTP request with an Upgrade: header, which is part of the HTTP spec allowing the connection to switch to another protocol. So yeah, just supporting HTTP on other ports will support websockets as well.

dts commented 8 years ago

Cool! By the way, dinghy is a candle in the dark, it's made my whole development environment unbeatably awesome.

codekitchen commented 8 years ago

Oh you are too kind, thanks.

If you (or anybody else) wants to take a stab at this, I think we'd basically need to iterate over all env vars with that prefix, then define additional upstream and server blocks in the "server" template https://github.com/codekitchen/dinghy-http-proxy/blob/master/nginx.tmpl#L47

I'd suggest something like HTTP_PORT_35736, which would more naturally allow us to add HTTPS_PORT_* later if we want to support SSL for these.

dts commented 8 years ago

I'm not particularly good at Go, but if I get some spare time, I'll definitely look into it.