Download & Install
The fastest way to put anything on the internet.
GoSDK
Get started with Go
Clone the ngrok Go SDK example:
git clone git@github.com:ngrok/go-sdk-example.git && cd go-sdk-exampleRun your app
NGROK_AUTHTOKEN=<YOUR_AUTHTOKEN> go run main.goDon’t have an authtoken? Sign up for a free account.
Open your ngrok URL in a browser to see it working!
You’re all set. What’s next?
1tp := `2on_http_request:3 # redirect users to Google to log in4 - actions:5 - type: oauth6 config:7 provider: google8 9 # allow logins *only* from acme.com10 - expressions:11 - "!actions.ngrok.oauth.identity.email.endsWith('@acme.com')"12 actions:13 - type: deny14`15 16fwd, err := ngrok.Forward(ctx, ngrok.WithUpstream("http://localhost:8085"), ngrok.WithTrafficPolicy(tp))Inspect every detail of your traffic
Watch the flow in real time, then dig into the headers, body, latency, response, and more for every request.
Peruse the Go SDK quickstart
Follow along to embed ngrok into your app and use Traffic Policy for auth and traffic transformation.
Bring your own domain
Paid featureCreate a DNS CNAME record to use your own domain name for your endpoint URL.
1func connectNgrok() {2 fwd, err := ngrok.Forward(context.Background(),3 ngrok.WithUpstream("http://localhost:8085"),4 ngrok.WithURL("app.acme.com"),5 )6}Listen, don't forward
Serve traffic directly on an ngrok listener without forwarding. Your handler receives connections straight from the internet.
1func main() {2 ln, _ := ngrok.Listen(ctx)3 http.Serve(ln, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {4 fmt.Fprintln(w, "Hello from ngrok-go!")5 }))6}