I’m facing a strange problem involving local port forwarding through a SSH tunnel.
My SSH server is connected to a network on which several web servers are running. The SSH server has access to these web servers and can curl them all, but the web servers are not accessible over the internet directly and are not running on the same machine as the SSH server. I would like to remotely SSH into my SSH server and set up local port forwarding from my local port 8080 to one of these web servers using a command like the following:
ssh -L 8080:10.100.1.50:80 joshua@10.100.0.40 -p 2222
(where 10.100.1.50 is the fake IP address of the web server and 10.100.0.40 is the fake IP address of the SSH server)
However, this does not work. When I browse to localhost:8080 on the SSH client computer, my browser tells me it cannot reach this page. As opposed to on the SSH server, where the browser displays the same page just fine (when I’m logged in with my user account joshua) Meanwhile my SSH client does establish a proper successful terminal/shell connection. I routinely see the following message appear in that terminal:
channel 2: open failed: connect failed: Connection refused
Adding the -vvv option to the SSH invocation does not reveal any errors.
My SSH server is running Ubuntu 24.04 with the ufw firewall.
My question is how it can be that I can curl 10.100.1.50:80 from the SSH server but not from the SSH client through a tunnel when logged in with the exact same user account?
I control both the firewalls on the SSH server and the web servers. I have not configured any special rules to open or close ports based on the origins of requests. Could it be a firewall misconfiguration? What kind of firewall configurations could lead to the behavior I observe?