I have been playing around with developing Facebook applications recently, and I have found it difficult to setup a development environment because to test my application, Facebook needs to access it on a remote server. If my application is running on my workstation which is behind a firewall, then Facebook has no way to access it.
A friend at work told me about The RFacebook Tunnel which allows Facebook to connect to a port on a remote server which tunnels its traffic to a local computer. That is exactly what I need, except that I'm using Java instead of Ruby to develop my application. I started looking into doing this reverse tunneling myself just using the command line and found out that it is very easy!
All I needed to do was to issue this command from my workstation:
ssh -gNR 8888:localhost:8080 www.myremoteserver.com
This creates the tunnel so that any requests to www.myremoteserver.com:8888 are forwarded to my workstation on port 8080. Voila! Now Facebook can easily access the web application I'm running locally behind a firewall.
There was one little thing I left out. In order to get the tunneling to forward traffic from machines other than myremoteserver.com, I had to edit /etc/ssh/sshd_config and add the following line:
This site has some more information on why I had to do that.