How to forward a tcp connection through the reverse proxy to keep the tcp session?

There is such a scheme
5d83d83d93ca2216015995.png
As can be seen from the scheme of the problem is high latency on the satellite channel. If the client requests via http\s http'and caching data, I found enough time to study and writing a proxy server for tcp connections found very little, I am interested in the question of how to forward tcp or udp connection is initially not knowing where to contact the client? my suggestion to use the package gopacket for whipping out the Protocol address and port where to forward the connection,as well as how to store these session when reconnecting, about know that we need the cache, but what exactly to store in it? tell me what to read and where to move.
March 30th 20 at 00:26
1 answer
March 30th 20 at 00:28
Solution
how to forward tcp or udp connection is initially not knowing where to contact the client?

For tcp in any way. A TCP connection is characterized by the quadruple (src_ip, src_port, dst_ip, dst_port). Not knowing where to contact the client, the four can not be obtained, and hence forward will not work.
UDP generally the Protocol without connections. Each message (datagram) is sent regardless of previous/next.

need cache, but what exactly to store in it?

The cache stores frequently used data.

As can be seen from the scheme of the problem is high latency on the satellite channel.

Put up a great keepalive and socket timeout.

Actually, I did not understand what is the problem described in the question. If You are writing a reverse proxy, read about how the Directive *upstream in nginx - can cereals diminished.
thanks for the reply! - delta commented on March 30th 20 at 00:31

Find more questions by tags ProxyComputer networksGoLinux