dinghy-http-proxy icon indicating copy to clipboard operation
dinghy-http-proxy copied to clipboard

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

Open dts opened this issue 9 years ago • 6 comments
trafficstars

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.

dts avatar Oct 02 '16 19:10 dts

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.

codekitchen avatar Oct 03 '16 15:10 codekitchen

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).

dts avatar Oct 04 '16 04:10 dts

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.

codekitchen avatar Oct 04 '16 14:10 codekitchen

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

dts avatar Oct 04 '16 17:10 dts

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.

codekitchen avatar Oct 04 '16 17:10 codekitchen

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

dts avatar Oct 04 '16 18:10 dts