Combine Pow and Ngrok for the win

If you need to share the advances of your web application with others, or simply you have to put it online quickly for whatever reason and you don't have time or money to setup a server, maybe this could help you.

Last weekend I had to do a demo of a web application that I'm developing on Rails, but I had no time to create a new online server and deploy it to production, so I decide to use a magical service that I discovered some time ago thanks to one of my coworkers: Ngrok.

So... What's Ngrok?

Ngrok it's a simple way to expose local servers behind NATs and firewalls to the public internet over secure tunnels. On a matter of seconds you can have your web application running online. First you have to create an account on ngrok.com in order to have a tunnel authtoken. Then simply get the binary from the download section, and configure your authtoken by executing on your terminal:

./ngrok authtoken YOUR_TUNNEL_AUTHTOKEN

Now you can start your first secure tunnel by executing:

./ngrok http 80

This is going to start the ngrok service, showing you an external URL like abcdefg.ngrok.io where your application will be reachable:

Ngrok screen

To see everything that is happening in the tunnel that ngrok has opened between your local machine and their service, you can open your browser and go to http://localhost:4040, where you will see a panel with all the information about the requests received by your application.

Ngrok panel

If you want to destroy the tunnel, just simply type Ctrl+C.

Ok, but what about Pow?

Pow is a zero-config Rack server for Mac OS X. I use Mac, but there are some other alternatives for Linux like Prax. You can see the Pow documentation here, but basically you only have to install it like:

$ curl get.pow.cx | sh

And then set up a Rack app, just by creating a symlink into ~/.pow:

$ cd ~/.pow
$ ln -s /path/to/some/railsapp

Your app will be up and running at http://railsapp.dev/.

So, once you have your Rails application configured with Pow, to put it online using Ngrok just type on your terminal something like this:

./ngrok http -host-header=railsapp.dev railsapp.dev:80

And there you have it! :)