I have the following situation: There are some hosts that are only accessible through an ssh tunnel. Lets say its
I can establish the SSH tunnel and bind the 443 ports needed for the connection to local ports:
ssh -L 1443:example.com:443 -L 2443:other.com:443 -A -l username myproxy.com
This works fine so far - when I call https://localhost:1443
, I can open example.com, if I call https://localhost:2443
, I can call other.com
The problem: There are some apps that are not aware of this and still try to connect via the regular hostname and port.
Adding the following lines to my hosts
file, I can get a step closer to the final solution:
127.0.0.1 example.com
127.0.0.1 other.com
This enables me to call https://example.com:1443
and https://other.com:2443
in my browser - but the port is still a problem. I would need to map BOTH domains to my local port 443
to make it work for other applications.
I guess I will need to have a local proxy server listening on port 443
and forwarding traffic based on hostname to either 1443
or 2443
but this is where I'm lost.
What can I do to enable all apps on my machine to just use the hostname/port but let the traffic go over my SSH tunnel?