ngrok is a globally distributed reverse proxy commonly used for quickly getting a public URL to a service running inside a private network, such as on your local laptop. The ngrok agent is usually deployed inside a private network and is used to communicate with the ngrok cloud service.


A full API reference is included in the ngrok go sdk documentation on Check out the ngrok Documentation for more information about what you can do with ngrok.

package main

import (


func main() {
	if err := run(context.Background()); err != nil {

func run(ctx context.Context) error {
	tun, err := ngrok.Listen(ctx,
	if err != nil {
		return err

	log.Println("tunnel created:", tun.URL())

	return http.Serve(tun, http.HandlerFunc(handler))

func handler(w http.ResponseWriter, r *http.Request) {
	fmt.Fprintln(w, "Hello from ngrok-go!")
Publikováno v Go