There’s actually a (really superb) Rust library/program for creating reverse tunnels over TCP, that’s called Rathole [0]. We used it [1] at my last startup and were mildly worried that one day we’d need to explain to a security auditor why we had a dependency called “rathole…”
[0] https://github.com/rapiz1/rathole
[1] https://www.splitgraph.com/jumpstart/tunnel