The following socat command can be used to listen on a local interface on a specific TCP port and tunnel the traffic via SSL to another host:port pair with forking:
socat TCP-LISTEN:<local_port>,bind=<local_interface>,fork SSL:<remote_host>:<remote_port>
Replace <local_port>
with the desired local TCP port number, <local_interface>
with the local interface IP address or hostname you want to bind to, <remote_host>
with the destination host IP address or hostname, and <remote_port>
with the destination port number.
For example, if you want to listen on localhost (127.0.0.1) on port 8080 and tunnel the traffic via SSL to example.com on port 443, you can use the following command:
socat TCP-LISTEN:8080,bind=127.0.0.1,fork SSL:example.com:443