Just to advertise about excellent ngrok open source project! To show you what exactly do ngrok, let me quot the http://www.ngrok.com website:
1. Demo your latest code
ngrok creates a tunnel from the public internet (http://subdomain.ngrok.com) to a port on your local machine. You can give this URL to anyone to allow them to try out a web site you're developing without doing any deployment.
2. Understand HTTP services
ngrok captures all traffic through the tunnel. It displays information about the HTTP traffic for your inspection. Raw request/response bytes, parsed headers and form data, JSON/XML syntax checking and more are included.
3. Replay Requests
Developing services which consume webhooks can be challenging if the hooks are labor-intensive to generate. Use ngrok's replay request feature to iterate quickly on a new feature without switching contexts to generate new requests.
Download and Installation (for Raspberry)
ngrok is easy to install. Download a single binary with zero run-time dependencies for any major platform. Unzip it and then run it from the command line. Ngrok run like a charm on a Raspberry, already complied for the ARM processor so, just download it:
https://dl.ngrok.com/linux_arm/ngrok.zip
Pricing & Features
ngrok.com is a pay-what-you-want service offered with no signup required. Many features are available for FREE to everyone, without signing up. Just download and run!
As said ngrok is an opensource project (https://github.com/inconshreveable/ngrok). You can run install and host and run your ngrok server, or SIMPLY you can use ngrok.com cloud server for basic usage; here you have many for free and some features are available under pay-what-you-want model. For my needs is essential the feature that allow to configure your Custom Subdomains: Pick a custom subdomain so your app appears on https://myapp.ngrok.com instead of http://a1b2c3d4.ngrok.com
To configure your subdomain, please above all do it here: https://ngrok.com/dashboard
Run ngrok as a Raspian daemon (my small contribute/tips):
for my project, a cloud server need to communicate with remote "terminals" (terminals are Raspberry HW with Raspian OS), I choose to implement "webhooks" to "push" data (ecommerce orders) to terminals. In this scenario each terminal:
A) run a webserver (Sinatra above Ruby in my case) that reply to HTTP REST APIs as
HTTP POST http://localhost:NNNN/neworder
HTTP GET http://localhost:NNNN/status
etc.
BTW, Please note the webserver in the case above reply from port number NNNN
In my case, as Rubyst, the API webserver is a simple Sinatra app, that do something like:
# myapp.rb
# require 'sinatra'
get '/status' do
# doing something
end
post '/neworder' do
# doing something
end
B) run a ngrok daemon that allow to publish to a internet address. This is possible using the (previously configured) subdomain GREAT feature of ngrok, and above mentioned endpoints become (please note that HTTPS is allowed too!):
HTTP POST https://myapp.ngrok.com/neworder
HTTP GET https://myapp.ngrok.com/status
etc.
A minor note about a possible ngrok client daemon script; I use this one:
#!/bin/bash
# this file: /your/path/ngrok.sh
TZ='Europe/Rome' /your/path/ngrok -config=/your/path/.ngrok -log=stdout -subdomain=myapp NNNN > /your/path/ngrok.log 2>&1 &
minor / stupid notes for beginners (as me):
TZ='Europe/Rome'
set the date inyour local time (I'm from Italy); that's necessary in case you run the daemon at startup (see below for details); otherwise yyou get UTC time.
/your/path/ngrok
run the ngrok client on your raspberry. The client connect to the ngrok.com server
-config=/your/path/.ngrok
.ngrok is the ngrok configuration file; it allow many things. polease read documentation: https://ngrok.com/usage
-subdomain=myapp NNNN
run ngrok with subdomain: myapp mapping localhost port number: NNNN
-log=stdout > /your/path/ngrok.log 2>&1
this let ngrok to NOT use default terminal mode mut instead force to write to log file: /your/path/ngrok.log eventually doing nothing > /dev/null
Important: I have the need to start @reboot the script above in a raspberry connected with a WiFI dongle.
The connectivity need some seconds (almost more than 20 in my case) so putting the script in crontab with @reboot was not a good idea (ngrok go down when start, if do not found networking). The solution come from rapdom (I thank you), here:
http://www.raspberrypi.org/forums/viewt ... 40#p559840
so let put in your /etc/network/interfaces config file this:
# this file: /etc/network/interfaces
# start ngrok after networking is up
post-up /your/path/ngrok.sh
Final notes
Forwarding non-HTTP services! Ngrok run also with TCP mode! that allow by example to SSH to your remote Rasberry ;-)
I come to ngrok after tested other localhost reverse tunnel sw as original Ruby localtunnel (ther are some realizations available also as open source projects). When discovered ngrok, I decided to use this one. I think is an excellent piece of software, written in Go language. It's a open source project.
Above all the ngrok's author, Alan Shreeve (contact@ngrok.com), is a very smart and generous person,
and if you enjoy using ngrok, let him know laso here: https://twitter.com/inconshreveable
I hope this help, i just my small contribute to thank you people in this forum often stand my questions and helped to solve things :-)
giorgio