What is Tunnelmole?

Tunnelmole is a straightforward open-source application that provides a public URL for a web server running locally. This can then be accessed from any device connected to the internet. In essence, Tunnelmole is a reverse proxy from the internet to your local machine, capable of handling all types of HTTP/HTTPS requests such as text, HTML, images, JavaScript, and JSON.

Since all requests are routed through the client app without initiating its own server, it bypasses network firewalls and routers. This means it can function even within a corporate network, VPN, or local area network (LAN) without needing any special network configuration or networking knowledge.

Tunnelmole can work with any kind of web server, including Nginx, native NodeJS applications, React applications and servers running within containerized environments like Docker, Kubernetes, or a Virtual Machine.

Getting Started

First, start your server. If you are unsure about how to do this, refer to your server’s documentation. Note down the port number on which your server is running. For instance, I have a simple NodeJS API server that uses express and will start with app.js, so I will run:

node app.js # This will start my express server

Then, run tmole <port>, where <port> is the port number.

My express server listens on port 3000. So, I will run:

$ tmole 3000
http://o0lktw.tunnelmole.com is forwarding to localhost:3000
https://o0lktw.tunnelmole.com is forwarding to localhost:3000

By following these steps, you now have two randomly generated URLs, one for HTTP and the other for HTTPS. You can send requests to your local server by using any HTTP client, such as a web browser, curl, or an API client like Postman, with these URLs. The server should function the same way it did when accessed through localhost or 127.0.0.1.

So, You’ve Got a Public URL for Your Local Server. Now What?

Free HTTPS

One of the benefits of using Tunnelmole is the ability is instant HTTPs without any additional config. Just use the HTTPs URL in the output and it will work out of the box.

HTTPS is mandatory for specific certain features of the web including but not limited to

  • Push Notifications
  • Geolocation (Location Access)
  • Service Workers
  • Payment Request API
  • Web Crypto API
  • Progressive Web Apps

Most web browsers will enforce this. Even if your server is running locally, these features require HTTPS. Therefore, something like http://localhost:3000 won’t work without overrides. You need to use a proper HTTPS URL, either one generated by Tunnelmole or one you configured yourself. Configuring HTTPs locally is complicated and can involve things like managing local certificate stores, self signed certificates, HTTPs exemptions and overrides etc.

To save yourself from all that trouble, just use the Tunnelmole HTTPs URL.

Mobile and Cross-Device Testing

Mobile testing differs from local testing. While you can use your computer’s web browser to view and test any web application running locally (for example, at http://localhost:3000 if it’s running on port 3000), you can’t use the same approach when testing from a mobile browser since its technically running on a different computer.

https://localhost:3000 doesn’t route anywhere on the mobile device because the service isn’t running there. By default, a mobile device cannot view anything running on your computer.

However, by entering your Tunnelmole URL into a mobile browser, you can view your locally running web application. While there are alternatives to this approach that require connecting cables/port forwarding, Tunnelmole simplifies the process.

The Tunnelmole URL works on other internet-connected devices and computers too. For example, you can access your website that is running on your Linux machine from a separate Mac or Windows machine for cross device testing.

Webhooks

Webhooks are API’s reverse; you’ll likely encounter them while integrating with services that provide webhooks, like Stripe, Twilio, and IFTTT. Instead of sending a HTTP request to an API, the service sends the request to you. Therefore, a public URL is necessary, as the services can’t access your localhost.

You can use your Tunnelmole HTTPS URL for this purpose. All you need to do is configure the Webhook URL to be your Tunnelmole URL in your service provider’s settings. Preferably, use the HTTPS URL as it is more secure and less likely to be rejected by providers.

Getting a Permanent URL

Tunnelmole supports custom subdomains. So, instead of using <random string>.tunnelmole.net, you can opt for yourdomain.tunnelmole.net.

The cost starts at around $9.99 per month, typically similar to the cost of owning your own cloud instance or VPS. To begin, sign up here. By signing up, you are supporting Tunnelmole’s ongoing development.

Once signed up, you can expose a web server with a custom subdomain by running tmole <port> as <your subdomain>.tunnelmole.net. If you want to use linuxhome.tunnelmole.com as your subdomain and your server is running on port 80, run tmole 80 as linuxhome.tunnelmole.net.

Here is the full command with a sample output:

$ tmole 80 as linuxhome.tunnelmole.com
http://linuxhome.tunnelmole.com is forwarding to localhost:80
https://linuxhome.tunnelmole.com is forwarding to localhost:80

Conclusion

At its core, Tunnelmole is a simple tool that generates a public URL for a local web server and doesn’t offer any other intricate features. Despite its simplicity, the URLs generated by Tunnelmole can be utilized in various scenarios. Hopefully, you will find these public URLs valuable.