A minimal Rust app demonstrating the ngrok Rust SDK.
- An ngrok account.
- Your ngrok auth token.
- Rust installed on your machine.
-
Build the project (this will download dependencies):
cargo build
-
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 update the
domain
variable insrc/endpoint.rs
.
-
Start the Rust service:
cargo run --bin service
-
In another terminal, start the ngrok agent endpoint:
NGROK_AUTHTOKEN=your_token_here cargo run --bin endpoint
Or if you created a
.env
file:cargo run --bin endpoint
The ngrok agent endpoint will output a URL that forwards traffic to your local app.
src/service.rs
- Basic Rust HTTP serversrc/endpoint.rs
- ngrok agent endpoint configuration with OAuth.env.example
- Environment variable templateCargo.toml
- Rust dependencies and binary configuration