https://github.com/kataras/tunnel
Public URLs for exposing your local web server
https://github.com/kataras/tunnel
go golang http iris ngrok tunneling
Last synced: 11 months ago
JSON representation
Public URLs for exposing your local web server
- Host: GitHub
- URL: https://github.com/kataras/tunnel
- Owner: kataras
- License: mit
- Created: 2020-07-10T06:58:24.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-24T06:22:47.000Z (about 3 years ago)
- Last Synced: 2025-02-27T17:45:58.978Z (12 months ago)
- Topics: go, golang, http, iris, ngrok, tunneling
- Language: Go
- Homepage:
- Size: 22.5 KB
- Stars: 26
- Watchers: 3
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Tunnel
[](https://github.com/kataras/tunnel/actions) [](https://goreportcard.com/report/github.com/kataras/tunnel) [](https://godoc.org/github.com/kataras/tunnel)
Public URLs for exposing your local web server using [ngrok's API](https://ngrok.com/).
## Installation
The only requirement is the [Go Programming Language](https://golang.org/dl).
```sh
$ go get github.com/kataras/tunnel@latest
```
## Getting Started
First of all, navigate to , create an [account](https://dashboard.ngrok.com/signup) and [download](https://dashboard.ngrok.com/get-started/setup) 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:
```sh
$ ngrok version
```
Import the package:
```go
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**:
```go
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
```go
config := tunnel.Configuration{
// 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:
```sh
• Public Address: https://ef02b1377b65.ngrok.io
```
> The [Web Interface](https://ngrok.com/docs#inspect) is also available.
Please navigate through [_examples](_examples) directory for more.
## License
This software is licensed under the [MIT License](LICENSE).