Tunnelmole

repository·main·Indexed 23 days ago

https://github.com/robbie-cahill/tunnelmole-client

An open-source ngrok alternative that provides instant public HTTP(s) URLs for locally running web servers, APIs, or applications. Available as a command line application (tmole) or as an NPM dependency for Node.js 16.10+. Supports custom subdomains via paid subscription or self-hosting, and works behind firewalls.

Tokens
1.3K
Snippets
7
Records
14
Agent score
84%

What's inside tunnelmole

  1. Use a custom subdomain with the CLI

    main

    To use a specific subdomain that does not change frequently, use the as keyword:

    tmole 8080 as <yourdomain>.tunnelmole.net

    Note: Using custom subdomains on the hosted service requires a paid subscription. Alternatively, you can self-host the Tunnelmole service.

  2. Use the Tunnelmole CLI to expose a local port

    main

    To create a public URL for a locally running server, run the tmole command followed by the port number your application is listening on.

    Example: If your app is on port 8080, run:

    tmole 8080

    This will output public HTTPs and HTTP URLs that tunnel to your local port.

  3. Install Tunnelmole pre-built binaries

    main

    You can install pre-built binaries for various platforms without needing a global npm installation.

    Linux, Mac and WSL

    Use the following curl command to run the installation script:

    curl -O https://install.tunnelmole.com/n3d5g/install && sudo bash install

    Windows

    1. Download tmole.exe.
    2. Add the directory containing tmole.exe to your system PATH.
  4. Configure Tunnelmole environment variables

    main

    Use environment variables to control Tunnelmole's behavior:

    • TUNNELMOLE_QUIET_MODE=1: Suppresses the initial console output containing the public URLs. Useful for CI/CD or automated scripts.
    • TUNNELMOLE_TELEMETRY=0: Disables the collection of anonymized telemetry data (NodeJS version, OS, and crash reports).
  5. Use the tunnelmole CLI to share local servers

    main

    The tunnelmole CLI (aliased as tmole) allows you to expose a local server running on a specific port to a public URL.

    Get a random public URL (Free)

    To get a random, temporary public URL, run the command followed by the port number: tmole <port>

    Example: If your server is on port 80, run tmole 80. Your server will be accessible via a random URL like https://f38fg.tunnelmole.net.

    Get a persistent public URL (Subscription required)

    To use a specific, unchanging subdomain, use the as syntax: tmole <port> as <subdomain>.tunnelmole.net

    Example: tmole 80 as myapi.tunnelmole.net. This requires a subscription and an API key.

    tmole 80
    tmole 80 as myapi.tunnelmole.net
  6. Integrate Tunnelmole with NPM scripts

    main

    When installed as an NPM dependency, you can use the local binaries tmole or tunnelmole located in node_modules/.bin/. This allows you to automate starting your app and the tunnel in a single command via package.json.

    Example package.json configuration:

    {
        "name": "myapp",
        "version": "0.0.1",
        "scripts": {
            "start": "dist/index.js",
            "start-public": "npm run start && tmole 3000"
        }
    }
  7. Use Tunnelmole as a dependency in your code

    main

    You can integrate Tunnelmole directly into your Node.js application (requires Node 16.10+).

    Installation

    npm install --save tunnelmole

    Implementation

    Import the tunnelmole function and call it with a configuration object. The function is async and returns the public URL. It starts the tunnel in the background and does not block the rest of your code execution.

    ES Module Import

    import { tunnelmole } from 'tunnelmole';

    CommonJS Import

    const tunnelmole = require('tunnelmole/cjs');

    Basic Usage

    const url = await tunnelmole({
        port: 3000
    });
    // url = https://idsq6j-ip-157-211-195-169.tunnelmole.net

    Usage with a custom domain

    const url = await tunnelmole({
        port: 3000,
        domain: '<your tunnelmole domain e.g. mysite.tunnelmole.net>'
    });
    const url = await tunnelmole({
        port: 3000
    });