Ramblings

April 15, 2008

Set up a remote forwaring port to develop Facebook apps locally

Filed under: cool, tip — michaelangela @ 8:36 pm

Oh this is so cool. Man webfaction is just changing my whole development life in a good way.

I want to be able to write an app in django with my normal tools here, but still have Facebook access it. I’ve done the “open the port on the router” bit and I don’t like it. I like ssh tunnels though. I hadn’t done remote port forwarding before but in starting to look for a solution, a comment on a post here said what I wanted to here. “Avoid the port-forwarding/NAT traversal/firewall morass”. Following the link, the interesting bit is this:

developing a facebook app locally :: snax

The
rake task opens an SSH connection to our server and forwards a port on
it to our local box. This will work no matter what kind of NAT or proxy
you are behind, as long as you can access your server via SSH.

It’s ruby specific stuff but I got the idea. It was doing the remote port forwarding. Now I come from 1&1. I am not used to the power and flexibility of webfaction so every time I learn something like this… it’s just groovy. Like just a couple of days ago I was informed that it’s possible to set up secure https/.htaccess protected webdav access to a folder you specify in your account. I haven’t had any trouble with 1&1 actually. And now they are the media server since the hard drive space is generous for the price.

So, with all the said, these are the steps for a webfaction user.

  • Set up a new app listening on a custom port
  • Set up a new subdomain for my custom app
  • Set up a new website connecting the new app with the new subdomain
  • Got the port of the app as listed in the control panel
  • Use 127.0.0.1 for the local host (localhost itself seemed not to work, but I haven’t tested extensively)
  • Command for term use is ssh -N -p 22 -c 3des your_username@your_ssh_server.webfactional.com -R port_of_app:127.0.0.1:local_server_port

I use SSH Tunnel Manager to manage tunnels on a mac instead of opening a bunch of iTerm shells. The settings look like:

  • Name: connection name
  • Login: your user name
  • Host: your_ssh_host.webfactional.com
  • Port: 22

Local Redirections

  • Empty

Remote Redirections

  • Port: port_to_app
  • Remote Host: 127.0.0.1
  • Port: local_port

I was a bit surprised to actually see my local dev server respond. 🙂 Now… just have to learn how to code it all… but this makes it a LOT easier. I can point the Facebook app url to my outside URL and test locally without copying files to a remote server for testing… though that is admittedly easier with Subclipse and ssh tunneling! Let’s see how it goes. Thanks webfaction!

Advertisements

1 Comment »

  1. Fantastic!

    This is a great technique, not just for Facebook but for development in general. I just setup a generic ‘dev’ subdomain that I’ll be using to tunnel back from a public URL.

    -Aaron
    http://www.aaronheld.com

    Comment by aaronheld — March 7, 2009 @ 2:30 am


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: