Search code examples
linuxsshssh-tunnel

Trouble SSH Tunneling to remote server


I am trying to get from my local machine to a remote vendor's website that is locked down by IP (our corporate servers are allowed access). I am doing this by tunneling from a server that can access the API without issues, however, when I setup the SSH tunnel and go to a URL on the vendor website, I get a 404 Not Found error. Here is what I'm using:

ssh -f -N user@example.com -L 7777:vendorhostexample.com:80

Everything indicates that the tunnel is setup correctly, but if I try a URL such as 'http://localhost:7777/foobar', I get the 404 error. Any ideas?


Solution

  • Your problem is you are sending the http header "Location: localhost" which means if the destination webserver is using virtualhosts, it will try to lookup for website "localhost" and not for website "vendorhostexample.com"

    One way is as Ryan pointed out to modify your hosts file and tell your machine that vendorhostexample.com it's on 127.0.0.1, that way when you type it in your browser you will go through the tunnel with the right "Host:" http header set.

    Another way it's installing an extension for your browser to change the Host header like this one for firefox.