In the following article, we are going to take a look at Localtunnel. This application will be useful in the event that we create a website on our local development server for a client. At some point, he will want to see how the work goes. If so, we could host the website on an online server, so the customer can see it. Another option would be to take a screenshot of each page of the website and send them to the client. But all this will no longer be necessary if we use localtunnel. This application will allow us to easily share the web server of our local development team.
What is localtunnel
Locatunnel (lt) is a CLI tool which 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. The default localtunnel client connects to the
It will assign a unique URL accessible to the public so that they can access your web server that runs locally. Localtunnel exposes your localhost to the world for easy testing and sharing which means that you expose your development server locally to the real world.
You can use the help to know how to use it
# lt --help Usage: lt --port [num] 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]
1) Install localtunnel
Localtunnel is installed on your system through nodejs as below:
# npm install -g localtunnel /usr/bin/lt -> /usr/lib/node_modules/localtunnel/bin/client + email@example.com added 75 packages in 19.427s
2) Share your local web server
Before sharing your local web server, you naturally need to have already installed your apache server and define the port which will be used. So, you will launch localtunnel with the port used by your local web server. In our case the port used is 80, you will do as below:
# lt --port 80 your url is: https://sfrfutsoky.localtunnel.me
The URL that the terminal provides will be the one that allows remote users to connect. It will connect to the tunnel server, setup the tunnel, and assign you a unique URL to use for your testing. This URL will remain active for the duration of the session. In the meantime, we can share it with others to test the web service or just share our work with whoever we want as below
3) Personalize your local web server subdomain
The automatic subdomain provides by the localtunnel command can be difficult to retain even if it is not an IP address. Fortunately, localtunnel allows you to request (assign) a personalize named subdomain on the localtunnel server that you will choose for your local web server. It can be done with the
--subdomain parameter as below:
# lt --port 80 --subdomain linoxserver your url is: https://linoxserver.localtunnel.me
You see that this new subdomain is easy to retain and we can share it with our clients
It is interesting to see that you don't always have to host a web server in order to make it accessible if it is for tests for example. Making your local server available online is probably the fastest way to cope with this, especially if you have hundreds of files that you require access to.