Sunday, February 10, 2008

SSH Tunnel For Local Facebook and OpenSocial development

One of the frustrating things for me (till now) when developing Facebook and OpenSocial Apps was that I constantly had to redeploy my code to our staging server, since I dont have a static IP and even if I make a reference to my dynamic IP with a service like dyndns.org I would still have to configure my Router so that requests get forwarded to my development machine. Furthermore, if you don't have access to your Router's settings your are out of luck.

Then I found an article about how to make a SSH Tunnel from your staging machine to your local development server.

One thing they don't mention in the article is to check for your Firewall settings on the remote machine. My Port 8090 was blocked, so I had to change the settings for that.

If you are working on Linux or Mac the article explains all the steps you have to go through to get it working. Since I am (still, but not for long anymore) working on a Windows machine I wanted to use something that I already have installed on my computer. So I started up Putty and tried to figure out how to configure it so that it starts up a tunnel. Here are the settings I used to get it working:



To redirect the Port of the Remote Machine you have entered above go to Connection>SSH>Tunnels. Check the Local ports accept connections from other hosts and add a new Forwarded Port by typing:
Source Port: 8090 in my case, but you might as well use another one
Destination: localhost:8080, since I am using Tomcat. Use :80 if you have an Apache running.
Then make sure that you check "Remote", since otherwise the ports are forwarded from your local machine to your Remote Server.


Save all of these Settings so all you have to do next time is to Start Putty, load the Settings and connect to your Remote Server. This will work from everywhere you go now (Starbucks ...) without further configuration.

Now check if the App you are building loads when you type http://my.staging.server.com:8090 into your browser. If yes, go to your Facebook and OpenSocial Apps and change the url.

OpenSocial, at least from Ning.com (I have not tried the others yet, but I will try MySpace and Orkut soon), will only load the Gadget XML file from Port :80. Therefore you have to add a forward from Port 80 to Putty, just like you have done it before with port 8090. Also check that your Apache does not run, since otherwise it is bound to Port :80 already and SSH can't connect.

0 comments: