Given an ssh tunnel created on machine A to machine B using e.g.
ssh -D 9999 user@remote-server-ip-machine-B
In php how would one make requests from machine A to machine C using stream_socket_client() such that those requests are made via the above tunnel e.g.
$socket = stream_socket_client("tls://$ip-machine-C:$port", $errno,$errstr, 60, STREAM_CLIENT_CONNECT, $context);
In other words, the requests must originate from a php script running on machine A made to machine C but to machine C the requests must look like they are coming from machine B (the connection made to machine C needs to be made using tls).
Or alternatively, is there a way to achieve the same end result directly in php without the ssh tunnel? Any help with this will be very much appreciated
I found the best way to solve this problem is to use a VPN like OpenVPN (connecting machine A to machine B) or a very useful script called sshuttle, which is a transparent proxy server that works as a poor man's VPN.