I have a specific problem where I have a host that cannot be connected to from outside IPs (let's call it server 1), but can initiate connections with other servers. However, I need to make a TCP server on this host accessible from outside connections on a specific port. I have another server with a static IP (server 2) that can be connected to directly, so I'm wondering, is it possible to essentially reverse the flow of traffic from server 1 so that connections are initiated from it instead of server 2 with HAProxy or a similar proxy server? Maybe something like:
Server 1 maintains a connection to server 2, and server 2 notifies server 1 whenever a connection is instantiated. Server 1 then connects to server 2, and server 2 routes all traffic (bidirectionally) to server 1. Server 1 then also connects this socket to the internal host TCP server and forwards all traffic to it.
Is this possible to do?