ngrok-rust
ngrok is a simplified API-first ingress-as-a-service that adds connectivity, security, and observability to your apps.
ngrok-rust, our native and idiomatic crate for adding a public internet address with secure ingress traffic directly into your Rust apps 🦀. If you’ve used ngrok in the past, you can think of ngrok-rust as the ngrok agent packaged as a Rust crate.
ngrok-rust lets developers serve Rust services on the internet in a single statement without setting up low-level network primitives like IPs, NAT, certificates, load balancers, and even ports! Applications using ngrok-rust listen on ngrok’s global ingress network for TCP and HTTP traffic. ngrok-rust listeners are usable with hyper Servers, and connections implement tokio’s AsyncRead and AsyncWrite traits. This makes it easy to add ngrok-rust into any application that’s built on hyper, such as the popular axum HTTP framework.
See /ngrok/examples/ for example usage, or the tests in
/ngrok/src/online_tests.rs.
For working with the ngrok API, check out the ngrok Rust API Client Library.
Installation
Add ngrok to the [dependencies] section of your Cargo.toml with cargo add:
Quickstart
Create a simple HTTP server using ngrok and axum:
Cargo.toml:
[]
= "ngrok-rust-demo"
= "0.1.0"
= "2021"
[]
= { = "0.14.0"}
= { = "1", = [
"full"
] }
= { = "0.7.4", = ["tokio"] }
= "0.1.59"
= { = "1", = ["full"]}
= { = "0.1", = [
"full"
] }
= "2.5.4"
src/main.rs:
use ;
use ;
use SocketAddr;
use Url;
async
Changelog
Changes to ngrok-rust are tracked under CHANGELOG.md.
Join the ngrok Community
- Check out our official docs
- Read about updates on our blog
- Open an issue or pull request
- Join our Slack community
- Follow us on X / Twitter (@ngrokHQ)
- Subscribe to our Youtube channel (@ngrokHQ)
License
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in ngrok by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.