Localtunnel – Easily share a local web server without hosting

In this article, we’ll take a look at Localtunnel. This application will be useful if we are creating a website on our local server for a client. At some point, he wants to see how the work is going. If so, then we could host the website on an internet server so that the client can see it. Another option would be to take a screenshot of every page of the website and send them to the client. But this will not be necessary if we use localtunnel. This application will make it easy to share your web server.

What is localtunnel

Locatunnel is a CLI tool that allows you to easily share a web service on your local developer machine without putting it on the internet or manipulating DNS and firewall settings. Localtunnel client connects to server by default localtunnel.me

It will be assigned a unique URL accessible from the outside so that they can access the local web server. Localtunnel exposes your localhost to the world for easy testing and sharing, which means you expose your development server locally to the real world.

You can use help to find out 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 via nodejs as shown below:

# npm install -g localtunnel
/usr/bin/lt -> /usr/lib/node_modules/localtunnel/bin/client
+ [email protected]
added 75 packages in 19.427s

2) Sharing local web server

Before you start sharing a local web server, of course, you need to have an Apache server installed and define the port that will be used. This way you will be running localtunnel with the port used by the local web server. In our case, port 80 is used, you will do as shown below:

# lt --port 80
your url is: https://andrey.localtunnel.me

The URL that the terminal provides will be one that allows remote users to connect. It will connect to the server using a tunnel, set up a tunnel, and assign you a unique URL to use for testing. This URL will remain active for the entire session. At the same time, we can share it with others to test the web service or just share our work with whoever we want, as shown below.

3) Setting up your local subdomain on the webserver

The automatic subdomain provided by the localtunnel command can be difficult to maintain, even if it is not an IP address. Fortunately, localtunnel allows you to request (assign) to personalize a named subdomain on a local server that you choose for your local web server. This can be done using the –subdomain parameter as shown below:

# lt --port 80 --subdomain andreyexserver
your url is: https://andreyexserver.localtunnel.me

You can see that this new subdomain is easy to save and we can share with our clients

It is interesting to see that you don’t always have to host a web server in order to make it available if it is for testing, for example. Making an accessible local server on the Internet is probably the fastest way to handle this, especially if you have hundreds of files to access.

Sidebar