Testing localhost with Mobile devices with Rails and Ngrok.

What if you need to test your localhost dev environment on your Android/iOS devices.

Ngrok is a service for secure tunnels to localhost, helps a lot when you need to test your localhost with mobile devices.

1.- Download
2.- Install your authtoken

ngrok authtoken laksdfjhalskdfhlaksdhfiqweo

3.- Create your first secure tunnel

ngrok http 80

What if you need advanced tunneling, for example, the architecture of your application needs subdomain support and SSL certificate you can use it like:

What you want to achieve: https://your_subdomain.localhost.com:3000

$ thin start -a localhost
$ ngrok http 3000 -subdomain=your_subdomain

This last comand will display something like this in your terminal:

Session Status                online  
Account                       zazvick (Plan: Basic)  
Version                       2.2.4  
Region                        United States (us)  
Web Interface         
Forwarding                    http://your_subdomain.ngrok.io -> localhost:3000  
Forwarding                    https://your_subdomain.ngrok.io -> localhost:3000

Connections                   ttl     opn     rt1     rt5     p50     p90  
                              0       0       0.00    0.00    0.00    0.00

So after this, you have this link https://your_subdomain.ngrok.io the one you can use on your devices Android/iOS or any browser and connect/interact with your localhost.

The downside for this specific example you need to pay ngrok but if you want the simple way the one you don't need support subdomains, you need just to create you account.

That's all folks!

Victor Velazquez

Coder, Musician, Startups, Passionate Dancer & Life Lover. Director of Engineering at MagmaLabs, Co-founder of Web Dev Talks, Co-founder of Voltaire, Co-founder of Paqkit, Ex-co-founder of Zaznova.

Subscribe to The zazvick's blog

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!