I've got a web server that isn't quite ready for general availability but I'd still like to test some things remotely. Can I leverage an SSH tunnel to connect to the server and then use the tunnel to route to the web service that is operating on the same server? If so how?

I realize that implementing firewall exceptions would be easier but that isn't an option at this time.

Sorry if this is confusing. I agree that it's a unique scenario.

CentOS 5.x


I know cherokee management works this way, so let's say you have bound your webserver to your localhost on port 8080

ssh -L 8080:localhost:8080 your_servers_ip

After that you can access the remote interface through http://localhost:8080 and every request will be forwarded to the remote IP running your webserver.

  • Thanks. On a side note, I also needed to modify my hosts file to leverage the address (as expected). – Mike B Jan 17 '12 at 19:05

What Lucas said, where "localhost" can also be any reachable IP address from the SSH host.

Note that if you're using name virtual hosts, you will also need to do a /etc/hosts hack, so that you append something to the existing line, something like:   localhost  secretwebserver.example.com

Your browser can then use http://secretwebserver.example.com:8080.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.