Skip to content

Repository files navigation

Tunnel

build status report card godocs

Public URLs for exposing your local web server using ngrok's API.

Installation

The only requirement is the Go Programming Language.

$ go get github.com/kataras/tunnel@latest

Getting Started

First of all, navigate to https://ngrok.com/, create an account and download ngrok. Extract the downloaded zip file anywhere you like and optionally add it to your PATH or NGROK system environment variable. Test if installation successfully completed by running the following command:

$ ngrok version

Import the package:

package main

import "github.com/kataras/tunnel"

Start a new local http Server and expose it to the internet using just a single new line of code:

func main() {
    // [...http.HandleFunc]

    srv := &http.Server{Addr: ":8080"}
    // 1 LOC:
    go fmt.Printf("• Public Address: %s\n", tunnel.MustStart(tunnel.WithServers(srv)))
    //
    srv.ListenAndServe()
}

OR

config := tunnel.Configuration{
    // AuthToken: "<YOUR_AUTHTOKEN>",
    // Bin: "C:/ngrok.exe",
    // WebInterface: "http://127.0.0.1:4040",
    // Region: "eu",
    Tunnels: []tunnel.Tunnel{
        {Name: "my-app", Addr: ":8080"},
    },
}
publicAddrs := tunnel.MustStart(config)
fmt.Printf("• Public Address: %s\n", publicAddrs)

Example output:

• Public Address: https://ef02b1377b65.ngrok.io

The Web Interface is also available.

Please navigate through _examples directory for more.

License

This software is licensed under the MIT License.

About

Public URLs for exposing your local web server

Topics

Resources

Code of conduct

Contributing

Stars

26 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Contributors

Languages