Using Localtunnel in Rails Application

Localtunnel, as the name indicates, allows you to share your local web server on the internet. This kind of technique is very useful in cases such as:-
  • You want to demonstrate your web applications to clients.
  • Testing the web applications for compatibility issues against various operating systems and web browsers
  • Testing your web applications for compatibility in various mobile devices.
It is very easy to use. Your web application will be shared on public internet in a couple of seconds while it is running on your local system. Lets go through a step by step procedure to tunnel our very own RoR apps: STEP 1: Firstly, you need to install the client library for Localtunnel. So just install it by installing the ‘localtunnel’ gem or write it in your Gemfile:-
gem 'localtunnel'
and run ‘bundle install’ STEP 2: Run your local web server on any port! Let’s say you’re running on port 8080.
$rails s -p 8080
STEP 3: Now run localtunnel by specifying it the on port to be shared as:-
$ localtunnel 8080
It will establish a connection between your local server running at 8080 and localtunnel.com. Note that for first time you run the localtunnel, it needs you to specify your ssh public key for authentication. Here’s an example:
$ localtunnel -k ~/.ssh/id_rsa.pub 8080
After running the above commands, you will see something like this: – Port 8080 is now publicly accessible from http://xyz.localtunnel.com … Enjoy Tunnelling your apps !!