Let us say you just have created a beautiful website on your local development system. The client wants to see your work. What will you do? You can either host the website online, so the client can view it. Or, screenshot each page of the website and send them to your client. Would you do that? Not necessarily! Meet Localtunnel that allows you to easily share a web service on your local development machine without putting it online or without messing with DNS and firewall settings. It assigns you an unique publicly accessible URL that will proxy all requests to your locally running webserver. To put this simply, you can expose your local development system to real world. In this brief tutorial, I will show you how to make your local server accessible online using Localtunnel in Unix-like systems.
To install Localtunnel on your local development system, you need NodeJS installed on your system. Refer the following link to install NodeJS on Linux systems.
Once NodeJS installed, run the following command to install Localtunnel:
$ sudo npm install -g localtunnel
Make Your Local Server Accessible Online Using Localtunnel
To make your local system accessible from everywhere (assuming your local system is running on port 80), run the following command from your terminal:
$ lt --port 80
Sample output would be:
your url is: https://gczjxjqvuc.localtunnel.me
That's it. It will connect to the tunnel server, setup the tunnel, and assign you an unique URL to use for your testing. This URL will remain active for the duration of your session; so feel free to share it with others for testing your webservice or just sharing your work. You can restart your local server if necessary. Localtunnel is smart enough to detect this and reconnect once it is back.
Here is how I access my local Ubuntu server from online.
You may find it difficult to remember the URL. To make it much easier to remember, use subdomain (If it is available) as shown below.
$ lt --port 80 --subdomain myubuntu your url is: https://myubuntu.localtunnel.me
Now, I can access my local Ubuntu system from anywhere using URL: https://myubuntu.localtunnel.me.
To check Localtunnel version, run:
$ lt --version 1.8.3
To get help:
$ lt --help Usage: /usr/local/bin/lt --port [num] <options> Options: -h, --host Upstream server providing forwarding [default: "http://localtunnel.me"] -s, --subdomain Request this subdomain -l, --local-host Tunnel traffic to this host instead of localhost, override Host header to this host -o, --open opens url in your browser -p, --port Internal http server port [required] --help Show this help and exit [boolean] --version Show version number [boolean]