Establish TCP connection to upstream when client connection made to listener

Phillip Odam phillip.odam at nitorgroup.com
Fri Mar 20 13:57:40 UTC 2020


Hi

I'm looking for when a client establishes a TCP connection to an IP and 
port, that NGINX is listening on, that NGINX, without waiting on data 
being transmitted from the client to NGINX, would establish a TCP 
connection to the upstream.

If such a capability were to exist I'd have thought it'd be documented 
either at http://nginx.org/en/docs/stream/ngx_stream_proxy_module.html 
or http://nginx.org/en/docs/stream/ngx_stream_core_module.html. So from 
what I gather the capability does not exist in NGINX and it's quite 
likely considered a good thing, NGINX won't establish a backend 
connection (tying up resources) simply based on an in bound connection.

Trouble with this though, NGINX then can't fully support reverse 
proxying protocols where the server provides a response upon TCP 
connection eg. SSH2, MySQL. You're instead dependent on the client 
handling the lack of initial server response and that after the client 
sends its first lot of data it'll then receive the server's initial 
response.

I've checked the way HAProxy works and it either by default establishes 
the backend TCP connection upon connection to the frontend or there's 
some switch I unknowingly flipped.

Presumably this isn't anything new, so please feel free to point me 
towards whatever I've failed to find myself and I'm interested in 
hearing others thoughts and experience with this aspect of NGINX if you 
have time to share.

Cheers

Phillip



More information about the nginx mailing list