How it works...

In our recipe, we define an upstream block, which is virtually identical to our HTTP load balancer configurations. We also specified a hash against the client's IP ($remote_addr), as any application which only has internal session tracking for authentication or similar would require re-authentication against each upstream server if new connections are made.

We have three upstream servers specified for this recipe, which again are against the loopback interface on the local server. Each instance of your TCP applications would need to be listening on 127.0.0.1 on ports 8101, 8102, and 8103 individually.

Our server block directive then tells NGINX to listen on port 7400. As we haven't specified a protocol, it will default to TCP. If you require UDP, you'll need to specify the protocol as a parameter. Consider this example:

listen 7400 udp; 

Lastly, we then configure a reverse proxy (proxy_pass) to our named upstream configuration tcpapppool.