NGINX stream module with dynamic upstreams
NGINX has had support for dynamic upstream modules for a while in the community distribution and examples abund. I think this is probably one of the clearest I could find. Finding a similar config for stream proxies turned out to be surprisingly hard, so here I'm sharing my solution in the hope that it can be useful to somebody. Or someone more experienced can point out a better alternative. In my case my upstream is an ELB which can and will change ip address often so using the static DNS name was not an option.