A minimal Go app demonstrating the ngrok Go SDK.
- An ngrok account.
- Your ngrok auth token.
- Go installed on your machine.
-
Install dependencies:
go mod tidy
-
Create a
.env
file from the example:cp .env.example .env
-
Add your ngrok auth token to the
.env
file:NGROK_AUTHTOKEN=your_actual_authtoken_here
-
Reserve a domain in the ngrok dashboard and add it to the
.env
file:NGROK_RESERVED_DOMAIN=your_actual_domain_here
-
Start the Go service:
go run service.go
-
In another terminal, start the ngrok agent endpoint:
go run endpoint.go
The ngrok agent endpoint will output a URL that forwards traffic to your local app.
service.go
- Basic Go HTTP serverendpoint.go
- ngrok agent endpoint configuration with OAuth.env.example
- Environment variable template