From 6275f515c947d6d1cb3f06d6998d32cc01c96aaa Mon Sep 17 00:00:00 2001 From: bobzilla Date: Thu, 19 Oct 2023 00:54:17 -0400 Subject: [PATCH] NodeJS & Python SDK examples and doc links (#449) --- docs/agent-sdks/index.mdx | 8 + docs/agent/ingress.mdx | 12 +- docs/cloud-edge/modules/user-agent-filter.md | 185 ------------------ docs/http/basic-auth.mdx | 14 +- docs/http/circuit-breaker.mdx | 14 +- docs/http/compression.mdx | 14 +- docs/http/index.mdx | 182 +++++++++++++---- docs/http/ip-restrictions.mdx | 14 +- docs/http/mutual-tls.mdx | 14 +- docs/http/oauth.mdx | 56 ++++-- docs/http/openid-connect.mdx | 17 +- docs/http/request-headers.mdx | 14 +- docs/http/response-headers.mdx | 14 +- docs/http/tls-termination.mdx | 14 +- docs/http/user-agent-filter.md | 14 +- docs/http/webhook-verification.mdx | 14 +- docs/http/websocket-tcp-converter.mdx | 14 +- docs/network-edge/gslb.mdx | 14 +- docs/tcp/index.mdx | 56 ++++-- docs/tcp/ip-restrictions.mdx | 14 +- docs/tls/index.mdx | 70 +++++-- docs/tls/ip-restrictions.mdx | 14 +- docs/tls/mutual-tls.mdx | 28 ++- docs/tls/tls-termination.mdx | 56 ++++-- examples/nodejs-sdk/custom-agent-ingress.mdx | 20 ++ examples/nodejs-sdk/explicit-region.mdx | 20 ++ examples/nodejs-sdk/http-basic-auth.mdx | 18 ++ examples/nodejs-sdk/http-branded-domain.mdx | 18 ++ examples/nodejs-sdk/http-circuit-breaker.mdx | 18 ++ examples/nodejs-sdk/http-compression.mdx | 18 ++ .../nodejs-sdk/http-fileserver-abs-path.mdx | 5 + .../nodejs-sdk/http-fileserver-windows.mdx | 5 + .../http-fileserver-working-dir.mdx | 5 + examples/nodejs-sdk/http-forward-https.mdx | 17 ++ examples/nodejs-sdk/http-ip-restrictions.mdx | 21 ++ examples/nodejs-sdk/http-mutual-tls.mdx | 19 ++ examples/nodejs-sdk/http-nonlocal.mdx | 17 ++ examples/nodejs-sdk/http-oauth-authn.mdx | 18 ++ examples/nodejs-sdk/http-oauth-authz.mdx | 21 ++ examples/nodejs-sdk/http-oauth-byo-app.mdx | 21 ++ .../http-oauth-customize-scopes.mdx | 21 ++ examples/nodejs-sdk/http-random.mdx | 18 ++ examples/nodejs-sdk/http-request-headers.mdx | 21 ++ examples/nodejs-sdk/http-response-headers.mdx | 24 +++ .../nodejs-sdk/http-rewrite-host-header.mdx | 18 ++ examples/nodejs-sdk/http-schemes.mdx | 17 ++ examples/nodejs-sdk/http-static-domain.mdx | 18 ++ examples/nodejs-sdk/http-tls-termination.mdx | 5 + .../nodejs-sdk/http-user-agent-filter.mdx | 21 ++ .../nodejs-sdk/http-webhook-verification.mdx | 20 ++ .../http-websocket-tcp-converter.mdx | 18 ++ examples/nodejs-sdk/http-wildcard-domain.mdx | 18 ++ examples/nodejs-sdk/tcp-fixed.mdx | 19 ++ examples/nodejs-sdk/tcp-ip-restrictions.mdx | 22 +++ examples/nodejs-sdk/tcp-nonlocal.mdx | 18 ++ examples/nodejs-sdk/tcp-proxyproto.mdx | 19 ++ examples/nodejs-sdk/tcp-random.mdx | 19 ++ examples/nodejs-sdk/tls-ip-restrictions.mdx | 22 +++ examples/nodejs-sdk/tls-mtls-at-agent.mdx | 5 + examples/nodejs-sdk/tls-mtls-at-edge.mdx | 27 +++ examples/nodejs-sdk/tls-proxyproto.mdx | 19 ++ .../nodejs-sdk/tls-reencrypt-upstream.mdx | 23 +++ .../nodejs-sdk/tls-terminate-at-agent.mdx | 5 + .../tls-terminate-at-edge-custom-cert.mdx | 22 +++ .../tls-terminate-at-edge-custom-domain.mdx | 26 +++ examples/nodejs-sdk/tls-terminate-at-edge.mdx | 23 +++ .../nodejs-sdk/tls-terminate-at-upstream.mdx | 19 ++ examples/python-sdk/custom-agent-ingress.mdx | 22 +++ examples/python-sdk/explicit-region.mdx | 22 +++ examples/python-sdk/http-basic-auth.mdx | 13 ++ examples/python-sdk/http-branded-domain.mdx | 13 ++ examples/python-sdk/http-circuit-breaker.mdx | 13 ++ examples/python-sdk/http-compression.mdx | 13 ++ .../python-sdk/http-fileserver-abs-path.mdx | 5 + .../python-sdk/http-fileserver-windows.mdx | 5 + .../http-fileserver-working-dir.mdx | 5 + examples/python-sdk/http-forward-https.mdx | 12 ++ examples/python-sdk/http-ip-restrictions.mdx | 15 ++ examples/python-sdk/http-mutual-tls.mdx | 17 ++ examples/python-sdk/http-nonlocal.mdx | 12 ++ examples/python-sdk/http-oauth-authn.mdx | 13 ++ examples/python-sdk/http-oauth-authz.mdx | 15 ++ examples/python-sdk/http-oauth-byo-app.mdx | 15 ++ .../http-oauth-customize-scopes.mdx | 16 ++ examples/python-sdk/http-random.mdx | 13 ++ examples/python-sdk/http-request-headers.mdx | 15 ++ examples/python-sdk/http-response-headers.mdx | 15 ++ .../python-sdk/http-rewrite-host-header.mdx | 13 ++ examples/python-sdk/http-schemes.mdx | 13 ++ examples/python-sdk/http-static-domain.mdx | 13 ++ examples/python-sdk/http-tls-termination.mdx | 5 + .../python-sdk/http-user-agent-filter.mdx | 15 ++ .../python-sdk/http-webhook-verification.mdx | 14 ++ .../http-websocket-tcp-converter.mdx | 13 ++ examples/python-sdk/http-wildcard-domain.mdx | 13 ++ examples/python-sdk/tcp-fixed.mdx | 14 ++ examples/python-sdk/tcp-ip-restrictions.mdx | 16 ++ examples/python-sdk/tcp-nonlocal.mdx | 13 ++ examples/python-sdk/tcp-proxyproto.mdx | 14 ++ examples/python-sdk/tcp-random.mdx | 13 ++ examples/python-sdk/tls-ip-restrictions.mdx | 16 ++ examples/python-sdk/tls-mtls-at-agent.mdx | 5 + examples/python-sdk/tls-mtls-at-edge.mdx | 22 +++ examples/python-sdk/tls-proxyproto.mdx | 14 ++ .../python-sdk/tls-reencrypt-upstream.mdx | 17 ++ .../python-sdk/tls-terminate-at-agent.mdx | 5 + .../tls-terminate-at-edge-custom-cert.mdx | 19 ++ .../tls-terminate-at-edge-custom-domain.mdx | 21 ++ examples/python-sdk/tls-terminate-at-edge.mdx | 17 ++ .../python-sdk/tls-terminate-at-upstream.mdx | 14 ++ examples/rust-sdk/http-schemes.mdx | 4 +- examples/rust-sdk/tcp-fixed.mdx | 1 - examples/rust-sdk/tls-reencrypt-upstream.mdx | 2 +- examples/rust-sdk/tls-terminate-at-edge.mdx | 3 + 114 files changed, 1902 insertions(+), 330 deletions(-) delete mode 100644 docs/cloud-edge/modules/user-agent-filter.md create mode 100644 examples/nodejs-sdk/custom-agent-ingress.mdx create mode 100644 examples/nodejs-sdk/explicit-region.mdx create mode 100644 examples/nodejs-sdk/http-basic-auth.mdx create mode 100644 examples/nodejs-sdk/http-branded-domain.mdx create mode 100644 examples/nodejs-sdk/http-circuit-breaker.mdx create mode 100644 examples/nodejs-sdk/http-compression.mdx create mode 100644 examples/nodejs-sdk/http-fileserver-abs-path.mdx create mode 100644 examples/nodejs-sdk/http-fileserver-windows.mdx create mode 100644 examples/nodejs-sdk/http-fileserver-working-dir.mdx create mode 100644 examples/nodejs-sdk/http-forward-https.mdx create mode 100644 examples/nodejs-sdk/http-ip-restrictions.mdx create mode 100644 examples/nodejs-sdk/http-mutual-tls.mdx create mode 100644 examples/nodejs-sdk/http-nonlocal.mdx create mode 100644 examples/nodejs-sdk/http-oauth-authn.mdx create mode 100644 examples/nodejs-sdk/http-oauth-authz.mdx create mode 100644 examples/nodejs-sdk/http-oauth-byo-app.mdx create mode 100644 examples/nodejs-sdk/http-oauth-customize-scopes.mdx create mode 100644 examples/nodejs-sdk/http-random.mdx create mode 100644 examples/nodejs-sdk/http-request-headers.mdx create mode 100644 examples/nodejs-sdk/http-response-headers.mdx create mode 100644 examples/nodejs-sdk/http-rewrite-host-header.mdx create mode 100644 examples/nodejs-sdk/http-schemes.mdx create mode 100644 examples/nodejs-sdk/http-static-domain.mdx create mode 100644 examples/nodejs-sdk/http-tls-termination.mdx create mode 100644 examples/nodejs-sdk/http-user-agent-filter.mdx create mode 100644 examples/nodejs-sdk/http-webhook-verification.mdx create mode 100644 examples/nodejs-sdk/http-websocket-tcp-converter.mdx create mode 100644 examples/nodejs-sdk/http-wildcard-domain.mdx create mode 100644 examples/nodejs-sdk/tcp-fixed.mdx create mode 100644 examples/nodejs-sdk/tcp-ip-restrictions.mdx create mode 100644 examples/nodejs-sdk/tcp-nonlocal.mdx create mode 100644 examples/nodejs-sdk/tcp-proxyproto.mdx create mode 100644 examples/nodejs-sdk/tcp-random.mdx create mode 100644 examples/nodejs-sdk/tls-ip-restrictions.mdx create mode 100644 examples/nodejs-sdk/tls-mtls-at-agent.mdx create mode 100644 examples/nodejs-sdk/tls-mtls-at-edge.mdx create mode 100644 examples/nodejs-sdk/tls-proxyproto.mdx create mode 100644 examples/nodejs-sdk/tls-reencrypt-upstream.mdx create mode 100644 examples/nodejs-sdk/tls-terminate-at-agent.mdx create mode 100644 examples/nodejs-sdk/tls-terminate-at-edge-custom-cert.mdx create mode 100644 examples/nodejs-sdk/tls-terminate-at-edge-custom-domain.mdx create mode 100644 examples/nodejs-sdk/tls-terminate-at-edge.mdx create mode 100644 examples/nodejs-sdk/tls-terminate-at-upstream.mdx create mode 100644 examples/python-sdk/custom-agent-ingress.mdx create mode 100644 examples/python-sdk/explicit-region.mdx create mode 100644 examples/python-sdk/http-basic-auth.mdx create mode 100644 examples/python-sdk/http-branded-domain.mdx create mode 100644 examples/python-sdk/http-circuit-breaker.mdx create mode 100644 examples/python-sdk/http-compression.mdx create mode 100644 examples/python-sdk/http-fileserver-abs-path.mdx create mode 100644 examples/python-sdk/http-fileserver-windows.mdx create mode 100644 examples/python-sdk/http-fileserver-working-dir.mdx create mode 100644 examples/python-sdk/http-forward-https.mdx create mode 100644 examples/python-sdk/http-ip-restrictions.mdx create mode 100644 examples/python-sdk/http-mutual-tls.mdx create mode 100644 examples/python-sdk/http-nonlocal.mdx create mode 100644 examples/python-sdk/http-oauth-authn.mdx create mode 100644 examples/python-sdk/http-oauth-authz.mdx create mode 100644 examples/python-sdk/http-oauth-byo-app.mdx create mode 100644 examples/python-sdk/http-oauth-customize-scopes.mdx create mode 100644 examples/python-sdk/http-random.mdx create mode 100644 examples/python-sdk/http-request-headers.mdx create mode 100644 examples/python-sdk/http-response-headers.mdx create mode 100644 examples/python-sdk/http-rewrite-host-header.mdx create mode 100644 examples/python-sdk/http-schemes.mdx create mode 100644 examples/python-sdk/http-static-domain.mdx create mode 100644 examples/python-sdk/http-tls-termination.mdx create mode 100644 examples/python-sdk/http-user-agent-filter.mdx create mode 100644 examples/python-sdk/http-webhook-verification.mdx create mode 100644 examples/python-sdk/http-websocket-tcp-converter.mdx create mode 100644 examples/python-sdk/http-wildcard-domain.mdx create mode 100644 examples/python-sdk/tcp-fixed.mdx create mode 100644 examples/python-sdk/tcp-ip-restrictions.mdx create mode 100644 examples/python-sdk/tcp-nonlocal.mdx create mode 100644 examples/python-sdk/tcp-proxyproto.mdx create mode 100644 examples/python-sdk/tcp-random.mdx create mode 100644 examples/python-sdk/tls-ip-restrictions.mdx create mode 100644 examples/python-sdk/tls-mtls-at-agent.mdx create mode 100644 examples/python-sdk/tls-mtls-at-edge.mdx create mode 100644 examples/python-sdk/tls-proxyproto.mdx create mode 100644 examples/python-sdk/tls-reencrypt-upstream.mdx create mode 100644 examples/python-sdk/tls-terminate-at-agent.mdx create mode 100644 examples/python-sdk/tls-terminate-at-edge-custom-cert.mdx create mode 100644 examples/python-sdk/tls-terminate-at-edge-custom-domain.mdx create mode 100644 examples/python-sdk/tls-terminate-at-edge.mdx create mode 100644 examples/python-sdk/tls-terminate-at-upstream.mdx diff --git a/docs/agent-sdks/index.mdx b/docs/agent-sdks/index.mdx index 7636dc4a0..c0d7194d2 100644 --- a/docs/agent-sdks/index.mdx +++ b/docs/agent-sdks/index.mdx @@ -7,6 +7,8 @@ import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem"; import RandomGoSdkExample from "/examples/go-sdk/http-random.mdx"; +import RandomNodejsSdkExample from "/examples/nodejs-sdk/http-random.mdx"; +import RandomPythonSdkExample from "/examples/python-sdk/http-random.mdx"; import RandomRustSdkExample from "/examples/rust-sdk/http-random.mdx"; # Agent SDKs @@ -25,6 +27,12 @@ ngrok's edge just as if you opened a socket to listen on a port. + + + + + + diff --git a/docs/agent/ingress.mdx b/docs/agent/ingress.mdx index cede93444..45419504b 100644 --- a/docs/agent/ingress.mdx +++ b/docs/agent/ingress.mdx @@ -10,6 +10,8 @@ import CustomIngressAgentCliExample from "/examples/agent-cli/custom-agent-ingre import CustomIngressAgentConfigExample from "/examples/agent-config/custom-agent-ingress.mdx"; import CustomIngressSshExample from "/examples/ssh/custom-agent-ingress.mdx"; import CustomIngressGoSdkExample from "/examples/go-sdk/custom-agent-ingress.mdx"; +import CustomIngressNodejsSdkExample from "/examples/nodejs-sdk/custom-agent-ingress.mdx"; +import CustomIngressPythonSdkExample from "/examples/python-sdk/custom-agent-ingress.mdx"; import CustomIngressRustSdkExample from "/examples/rust-sdk/custom-agent-ingress.mdx"; # Agent Ingress Address @@ -69,10 +71,16 @@ configuration file: - + - + + + + + + + diff --git a/docs/cloud-edge/modules/user-agent-filter.md b/docs/cloud-edge/modules/user-agent-filter.md deleted file mode 100644 index 888539bc4..000000000 --- a/docs/cloud-edge/modules/user-agent-filter.md +++ /dev/null @@ -1,185 +0,0 @@ -# User Agent Filter - ---- - -## Overview - -With the User Agent Filter module, you can allow or deny traffic through regular expression-based rules that are matched against the incoming `User-Agent` header. The `User-Agent` header contains information about the requesting browser or application, including its name, version, and operating system. - -Since rules are processed at the ngrok Cloud Edge, you can bolster your application’s security by blocking unwanted or unauthorized requests from known bots and malicious actors before it ever reaches your network. - -## Quickstart - -### Agent CLI - -```bash -ngrok http 80 \ - --ua-filter-allow="(foo/(\d)+.(\d)+)","(bar/(\d)+.(\d)+)" \ - --ua-filter-deny="(buz/(\d)+.(\d)+)" -``` - -### Agent Configuration File - -```yaml -tunnels: - example: - proto: http - addr: 80 - user_agent_filter: - allow: ["(foo/(\d)+.(\d)+)", "(bar/(\d)+.(\d)+)"] - deny: ["(buzz/(\d)+.(\d)+)"] -``` - -### Go SDK - -Here is an example using the [ngrok-go](https://github.com/ngrok/ngrok-go) library - -```go -package main - -import ( - "context" - "fmt" - "log" - "net/http" - - "golang.ngrok.com/ngrok" - "golang.ngrok.com/ngrok/config" -) - -func main() { - if err := run(context.Background()); err != nil { - log.Fatal(err) - } -} - -func run(ctx context.Context) error { - tun, err := ngrok.Listen(ctx, - config.HTTPEndpoint( - config.WithAllowUserAgent(`(foo)/(\d)+.(\d)+`), - config.WithDenyUserAgent(`(bar)/(\d)+.(\d)+`), - ), - ngrok.WithAuthtokenFromEnv(), - ) - 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.

") -} -``` - -### Rust SDK - -Here is an example using the [ngrok-rust](https://github.com/ngrok/ngrok-rust) library - -```rust -use axum::{routing::get, Router}; -use ngrok::prelude::*; -use std::error::Error; - -#[tokio::main] -async fn main() -> Result<(), Box> { - let app = Router::new().route("/", get(|| async { "Hello from ngrok-rust!" })); - - let listener = ngrok::Session::builder() - .authtoken_from_env() - .connect() - .await? - .http_endpoint() - .allow_user_agent(r"foo/(\d)+") - .allow_user_agent(r"bar/(\d)+") - .deny_ua(r"buz/(\d)+") - .listen() - .await?; - println!("Ingress URL: {:?}", listener.url()); - axum::Server::builder(listener) - .serve(app.into_make_service()) - .await?; - Ok(()) -} -``` - -## Behavior - -### Rule Evaluation - -On request, the User Agent Filter module will check the incoming `User-Agent` header value against the list of defined allow and deny regular expression rules. - -- Requests without the `User-Agent` header will be denied by default. To allow these requests, you can add an `allow` rule for empty strings: `^$` -- Requests with multiple `User-Agent` headers will only match the first header. - -### Match Behavior - -Requests are allowed if they match any allow rule or fail to match all deny rules. - -You can override `deny` rules by defining an `allow` rule that is more specific, for instance blocking all Google bots except Google Images: - -```json -{ - "allow": ["(?i)google-images"] - "deny": ["(?i)google", "[Bb]ing"] -} -``` - -## Reference - -### Configuration - -###### **Agent Configuration** - -| Parameter | Description | -| --------------------------- | ---------------------------------------------------------------------------- | -| **User Agent Filter Allow** | A set of regular expressions used to match User-Agents that will be allowed. | -| **User Agent Filter Deny** | A set of regular expressions used to match User-Agents that will be denied. | - -### Upstream Headers {#upstream-headers} - -This module does not add any upstream headers. - -### Errors - -| Code | HTTP Status | Error | -| ----------------------------------------- | ----------- | ----------------------------------------------------------- | -| [ERR_NGROK_3211](/errors/err_ngrok_3211/) | `403` | The server does not authorize requests from your user-agent | - -### Events - -When the User Agent Filter module is enabled, it populates the following -fields in the -[http_request_complete.v0](/obs/reference/#http-request-complete) event: - -| Fields | -| ---------------------------- | -| `user_agent_filter.decision` | - -### Limits - -This module is available on all plans. - -## Try it out - -Run ngrok with User Agent Filter's `allow` and `deny` set to the following: - -```bash -ngrok http 80 \ - --domain your-domain.ngrok.app \ - --ua-filter-allow="(GoingMerry/(\d)+.(\d)+)","(GomuGomu/(\d)+.(\d)+)" \ - --ua-filter-deny="(Xebec/(\d)+.(\d)+)" -``` - -Then make requests to your ngrok domain with the following: - -```bash -curl --location https://your-domain.ngrok.app -H 'Content-Type: text/plain' -A 'GoingMerry/1.1' --data 'https://www.youtube.com/watch?v=djyTG19Achg' -k -v -curl --location https://your-domain.ngrok.app -H 'Content-Type: text/plain' -A 'GomuGomu/1.1' --data 'https://www.youtube.com/watch?v=djyTG19Achg' -k -v -curl --location https://your-domain.ngrok.app -H 'Content-Type: text/plain' -A 'Xebec/1.1' --data 'https://www.youtube.com/watch?v=djyTG19Achg' -k -v -curl --location https://your-domain.ngrok.app -H 'Content-Type: text/plain' -A '' --data 'https://www.youtube.com/watch?v=djyTG19Achg' -k -v -curl --location https://your-domain.ngrok.app -H 'Content-Type: text/plain' -A 'TwitterBot/1.1' --data 'https://www.youtube.com/watch?v=djyTG19Achg' -k -v -``` diff --git a/docs/http/basic-auth.mdx b/docs/http/basic-auth.mdx index f3814ac23..20531a903 100644 --- a/docs/http/basic-auth.mdx +++ b/docs/http/basic-auth.mdx @@ -5,6 +5,8 @@ import AgentCliExample from "/examples/agent-cli/http-basic-auth.mdx"; import AgentConfigExample from "/examples/agent-config/http-basic-auth.mdx"; import SshExample from "/examples/ssh/http-basic-auth.mdx"; import GoSdkExample from "/examples/go-sdk/http-basic-auth.mdx"; +import NodejsSdkExample from "/examples/nodejs-sdk/http-basic-auth.mdx"; +import PythonSdkExample from "/examples/python-sdk/http-basic-auth.mdx"; import RustSdkExample from "/examples/rust-sdk/http-basic-auth.mdx"; # Basic Auth @@ -25,16 +27,22 @@ Allow requests from two different users, each with a different password. - + - + - + + + + + + + diff --git a/docs/http/circuit-breaker.mdx b/docs/http/circuit-breaker.mdx index 3e526e025..2ce85b0da 100644 --- a/docs/http/circuit-breaker.mdx +++ b/docs/http/circuit-breaker.mdx @@ -5,6 +5,8 @@ import AgentCliExample from "/examples/agent-cli/http-circuit-breaker.mdx"; import AgentConfigExample from "/examples/agent-config/http-circuit-breaker.mdx"; import SshExample from "/examples/ssh/http-circuit-breaker.mdx"; import GoSdkExample from "/examples/go-sdk/http-circuit-breaker.mdx"; +import NodejsSdkExample from "/examples/nodejs-sdk/http-circuit-breaker.mdx"; +import PythonSdkExample from "/examples/python-sdk/http-circuit-breaker.mdx"; import RustSdkExample from "/examples/rust-sdk/http-circuit-breaker.mdx"; # Circuit Breaker @@ -37,16 +39,22 @@ responses have 5XX status codes. - + - + - + + + + + + + diff --git a/docs/http/compression.mdx b/docs/http/compression.mdx index 5783a44a8..62f100ed8 100644 --- a/docs/http/compression.mdx +++ b/docs/http/compression.mdx @@ -5,6 +5,8 @@ import AgentCliExample from "/examples/agent-cli/http-compression.mdx"; import AgentConfigExample from "/examples/agent-config/http-compression.mdx"; import SshExample from "/examples/ssh/http-compression.mdx"; import GoSdkExample from "/examples/go-sdk/http-compression.mdx"; +import NodejsSdkExample from "/examples/nodejs-sdk/http-compression.mdx"; +import PythonSdkExample from "/examples/python-sdk/http-compression.mdx"; import RustSdkExample from "/examples/rust-sdk/http-compression.mdx"; # Compression @@ -27,16 +29,22 @@ takes no action. - + - + - + + + + + + + diff --git a/docs/http/index.mdx b/docs/http/index.mdx index 1b13dd4de..ad1f7c1b9 100644 --- a/docs/http/index.mdx +++ b/docs/http/index.mdx @@ -11,6 +11,8 @@ import RandomAgentCliExample from "/examples/agent-cli/http-random.mdx"; import RandomAgentConfigExample from "/examples/agent-config/http-random.mdx"; import RandomSshExample from "/examples/ssh/http-random.mdx"; import RandomGoSdkExample from "/examples/go-sdk/http-random.mdx"; +import RandomNodejsSdkExample from "/examples/nodejs-sdk/http-random.mdx"; +import RandomPythonSdkExample from "/examples/python-sdk/http-random.mdx"; import RandomRustSdkExample from "/examples/rust-sdk/http-random.mdx"; import StaticDomainKubernetesExample from "/examples/k8s/http-static-domain.mdx"; @@ -18,6 +20,8 @@ import StaticDomainAgentCliExample from "/examples/agent-cli/http-static-domain. import StaticDomainAgentConfigExample from "/examples/agent-config/http-static-domain.mdx"; import StaticDomainSshExample from "/examples/ssh/http-static-domain.mdx"; import StaticDomainGoSdkExample from "/examples/go-sdk/http-static-domain.mdx"; +import StaticDomainNodejsSdkExample from "/examples/nodejs-sdk/http-static-domain.mdx"; +import StaticDomainPythonSdkExample from "/examples/python-sdk/http-static-domain.mdx"; import StaticDomainRustSdkExample from "/examples/rust-sdk/http-static-domain.mdx"; import BrandedDomainKubernetesExample from "/examples/k8s/http-branded-domain.mdx"; @@ -25,6 +29,8 @@ import BrandedDomainAgentCliExample from "/examples/agent-cli/http-branded-domai import BrandedDomainAgentConfigExample from "/examples/agent-config/http-branded-domain.mdx"; import BrandedDomainSshExample from "/examples/ssh/http-branded-domain.mdx"; import BrandedDomainGoSdkExample from "/examples/go-sdk/http-branded-domain.mdx"; +import BrandedDomainNodejsSdkExample from "/examples/nodejs-sdk/http-branded-domain.mdx"; +import BrandedDomainPythonSdkExample from "/examples/python-sdk/http-branded-domain.mdx"; import BrandedDomainRustSdkExample from "/examples/rust-sdk/http-branded-domain.mdx"; import BasicAuthKubernetesExample from "/examples/k8s/http-basic-auth.mdx"; @@ -32,6 +38,8 @@ import BasicAuthAgentCliExample from "/examples/agent-cli/http-basic-auth.mdx"; import BasicAuthAgentConfigExample from "/examples/agent-config/http-basic-auth.mdx"; import BasicAuthSshExample from "/examples/ssh/http-basic-auth.mdx"; import BasicAuthGoSdkExample from "/examples/go-sdk/http-basic-auth.mdx"; +import BasicAuthNodejsSdkExample from "/examples/nodejs-sdk/http-basic-auth.mdx"; +import BasicAuthPythonSdkExample from "/examples/python-sdk/http-basic-auth.mdx"; import BasicAuthRustSdkExample from "/examples/rust-sdk/http-basic-auth.mdx"; import OAuthKubernetesExample from "/examples/k8s/http-oauth-authn.mdx"; @@ -39,6 +47,8 @@ import OAuthAgentCliExample from "/examples/agent-cli/http-oauth-authn.mdx"; import OAuthAgentConfigExample from "/examples/agent-config/http-oauth-authn.mdx"; import OAuthSshExample from "/examples/ssh/http-oauth-authn.mdx"; import OAuthGoSdkExample from "/examples/go-sdk/http-oauth-authn.mdx"; +import OAuthNodejsSdkExample from "/examples/nodejs-sdk/http-oauth-authn.mdx"; +import OAuthPythonSdkExample from "/examples/python-sdk/http-oauth-authn.mdx"; import OAuthRustSdkExample from "/examples/rust-sdk/http-oauth-authn.mdx"; import ForwardHttpsKubernetesExample from "/examples/k8s/http-forward-https.mdx"; @@ -46,6 +56,8 @@ import ForwardHttpsAgentCliExample from "/examples/agent-cli/http-forward-https. import ForwardHttpsAgentConfigExample from "/examples/agent-config/http-forward-https.mdx"; import ForwardHttpsSshExample from "/examples/ssh/http-forward-https.mdx"; import ForwardHttpsGoSdkExample from "/examples/go-sdk/http-forward-https.mdx"; +import ForwardHttpsNodejsSdkExample from "/examples/nodejs-sdk/http-forward-https.mdx"; +import ForwardHttpsPythonSdkExample from "/examples/python-sdk/http-forward-https.mdx"; import ForwardHttpsRustSdkExample from "/examples/rust-sdk/http-forward-https.mdx"; import HostHeaderKubernetesExample from "/examples/k8s/http-rewrite-host-header.mdx"; @@ -53,6 +65,8 @@ import HostHeaderAgentCliExample from "/examples/agent-cli/http-rewrite-host-hea import HostHeaderAgentConfigExample from "/examples/agent-config/http-rewrite-host-header.mdx"; import HostHeaderSshExample from "/examples/ssh/http-rewrite-host-header.mdx"; import HostHeaderGoSdkExample from "/examples/go-sdk/http-rewrite-host-header.mdx"; +import HostHeaderNodejsSdkExample from "/examples/nodejs-sdk/http-rewrite-host-header.mdx"; +import HostHeaderPythonSdkExample from "/examples/python-sdk/http-rewrite-host-header.mdx"; import HostHeaderRustSdkExample from "/examples/rust-sdk/http-rewrite-host-header.mdx"; import WildcardKubernetesExample from "/examples/k8s/http-wildcard-domain.mdx"; @@ -60,6 +74,8 @@ import WildcardAgentCliExample from "/examples/agent-cli/http-wildcard-domain.md import WildcardAgentConfigExample from "/examples/agent-config/http-wildcard-domain.mdx"; import WildcardSshExample from "/examples/ssh/http-wildcard-domain.mdx"; import WildcardGoSdkExample from "/examples/go-sdk/http-wildcard-domain.mdx"; +import WildcardNodejsSdkExample from "/examples/nodejs-sdk/http-wildcard-domain.mdx"; +import WildcardPythonSdkExample from "/examples/python-sdk/http-wildcard-domain.mdx"; import WildcardRustSdkExample from "/examples/rust-sdk/http-wildcard-domain.mdx"; import NonLocalKubernetesExample from "/examples/k8s/http-nonlocal.mdx"; @@ -67,6 +83,8 @@ import NonLocalAgentCliExample from "/examples/agent-cli/http-nonlocal.mdx"; import NonLocalAgentConfigExample from "/examples/agent-config/http-nonlocal.mdx"; import NonLocalSshExample from "/examples/ssh/http-nonlocal.mdx"; import NonLocalGoSdkExample from "/examples/go-sdk/http-nonlocal.mdx"; +import NonLocalNodejsSdkExample from "/examples/nodejs-sdk/http-nonlocal.mdx"; +import NonLocalPythonSdkExample from "/examples/python-sdk/http-nonlocal.mdx"; import NonLocalRustSdkExample from "/examples/rust-sdk/http-nonlocal.mdx"; import AbsPathFileserverKubernetesExample from "/examples/k8s/http-fileserver-abs-path.mdx"; @@ -74,6 +92,8 @@ import AbsPathFileserverAgentCliExample from "/examples/agent-cli/http-fileserve import AbsPathFileserverAgentConfigExample from "/examples/agent-config/http-fileserver-abs-path.mdx"; import AbsPathFileserverSshExample from "/examples/ssh/http-fileserver-abs-path.mdx"; import AbsPathFileserverGoSdkExample from "/examples/go-sdk/http-fileserver-abs-path.mdx"; +import AbsPathFileserverNodejsSdkExample from "/examples/nodejs-sdk/http-fileserver-abs-path.mdx"; +import AbsPathFileserverPythonSdkExample from "/examples/python-sdk/http-fileserver-abs-path.mdx"; import AbsPathFileserverRustSdkExample from "/examples/rust-sdk/http-fileserver-abs-path.mdx"; import WorkingDirFileserverKubernetesExample from "/examples/k8s/http-fileserver-working-dir.mdx"; @@ -81,6 +101,8 @@ import WorkingDirFileserverAgentCliExample from "/examples/agent-cli/http-filese import WorkingDirFileserverAgentConfigExample from "/examples/agent-config/http-fileserver-working-dir.mdx"; import WorkingDirFileserverSshExample from "/examples/ssh/http-fileserver-working-dir.mdx"; import WorkingDirFileserverGoSdkExample from "/examples/go-sdk/http-fileserver-working-dir.mdx"; +import WorkingDirFileserverNodejsSdkExample from "/examples/nodejs-sdk/http-fileserver-working-dir.mdx"; +import WorkingDirFileserverPythonSdkExample from "/examples/python-sdk/http-fileserver-working-dir.mdx"; import WorkingDirFileserverRustSdkExample from "/examples/rust-sdk/http-fileserver-working-dir.mdx"; import WindowsFileserverKubernetesExample from "/examples/k8s/http-fileserver-windows.mdx"; @@ -88,6 +110,8 @@ import WindowsFileserverAgentCliExample from "/examples/agent-cli/http-fileserve import WindowsFileserverAgentConfigExample from "/examples/agent-config/http-fileserver-windows.mdx"; import WindowsFileserverSshExample from "/examples/ssh/http-fileserver-windows.mdx"; import WindowsFileserverGoSdkExample from "/examples/go-sdk/http-fileserver-windows.mdx"; +import WindowsFileserverNodejsSdkExample from "/examples/nodejs-sdk/http-fileserver-windows.mdx"; +import WindowsFileserverPythonSdkExample from "/examples/python-sdk/http-fileserver-windows.mdx"; import WindowsFileserverRustSdkExample from "/examples/rust-sdk/http-fileserver-windows.mdx"; import SchemesKubernetesExample from "/examples/k8s/http-schemes.mdx"; @@ -95,6 +119,8 @@ import SchemesAgentCliExample from "/examples/agent-cli/http-schemes.mdx"; import SchemesAgentConfigExample from "/examples/agent-config/http-schemes.mdx"; import SchemesSshExample from "/examples/ssh/http-schemes.mdx"; import SchemesGoSdkExample from "/examples/go-sdk/http-schemes.mdx"; +import SchemesNodejsSdkExample from "/examples/nodejs-sdk/http-schemes.mdx"; +import SchemesPythonSdkExample from "/examples/python-sdk/http-schemes.mdx"; import SchemesRustSdkExample from "/examples/rust-sdk/http-schemes.mdx"; # HTTP Endpoints @@ -119,16 +145,22 @@ Create an HTTPS endpoint on a randomly assigned ngrok domain. - + - + - + + + + + + + @@ -146,16 +178,22 @@ Create an HTTPS endpoint on `example.ngrok.app` - + - + - + + + + + + + @@ -180,16 +218,22 @@ domains](/docs/network-edge/#branded-domains) for additional details. - + - + - + + + + + + + @@ -207,16 +251,22 @@ Adds a username and password with the [Basic Auth Module](/http/basic-auth). - + - + - + + + + + + + @@ -235,16 +285,22 @@ identity provider like Google with the [OAuth Module](/http/oauth/). - + - + - + + + + + + + @@ -263,16 +319,22 @@ service](#upstream-https-servers). - + - + - + + + + + + + @@ -293,16 +355,22 @@ header instead of appending a second value. - + - + - + + + + + + + @@ -320,16 +388,22 @@ Forward traffic to a HTTP server running on your network at `192.168.1.2:80`. - + - + - + + + + + + + @@ -349,16 +423,22 @@ wildcard domains](/network-edge/domains-and-tcp-addresses/#wildcard-domains). - + - + - + + + + + + + @@ -379,16 +459,22 @@ just like `python3 -m http.server` but built directly into the ngrok agent. - + - + - + + + + + + + @@ -404,16 +490,22 @@ just like `python3 -m http.server` but built directly into the ngrok agent. - + - + - + + + + + + + @@ -429,16 +521,22 @@ just like `python3 -m http.server` but built directly into the ngrok agent. - + - + - + + + + + + + @@ -458,16 +556,22 @@ endpoint as well. - + - + - + + + + + + + diff --git a/docs/http/ip-restrictions.mdx b/docs/http/ip-restrictions.mdx index a1dd22ccf..52fd6c66c 100644 --- a/docs/http/ip-restrictions.mdx +++ b/docs/http/ip-restrictions.mdx @@ -5,6 +5,8 @@ import AgentCliExample from "/examples/agent-cli/http-ip-restrictions.mdx"; import AgentConfigExample from "/examples/agent-config/http-ip-restrictions.mdx"; import SshExample from "/examples/ssh/http-ip-restrictions.mdx"; import GoSdkExample from "/examples/go-sdk/http-ip-restrictions.mdx"; +import NodejsSdkExample from "/examples/nodejs-sdk/http-ip-restrictions.mdx"; +import PythonSdkExample from "/examples/python-sdk/http-ip-restrictions.mdx"; import RustSdkExample from "/examples/rust-sdk/http-ip-restrictions.mdx"; # IP Restrictions @@ -29,16 +31,22 @@ Allow TCP connections from `110.0.0.0/8` and `220.12.0.0/16` but not from - + - + - + + + + + + + diff --git a/docs/http/mutual-tls.mdx b/docs/http/mutual-tls.mdx index 6b01d1111..c3a48fd74 100644 --- a/docs/http/mutual-tls.mdx +++ b/docs/http/mutual-tls.mdx @@ -5,6 +5,8 @@ import AgentCliExample from "/examples/agent-cli/http-mutual-tls.mdx"; import AgentConfigExample from "/examples/agent-config/http-mutual-tls.mdx"; import SshExample from "/examples/ssh/http-mutual-tls.mdx"; import GoSdkExample from "/examples/go-sdk/http-mutual-tls.mdx"; +import NodejsSdkExample from "/examples/nodejs-sdk/http-mutual-tls.mdx"; +import PythonSdkExample from "/examples/python-sdk/http-mutual-tls.mdx"; import RustSdkExample from "/examples/rust-sdk/http-mutual-tls.mdx"; # Mutual TLS @@ -30,16 +32,22 @@ one of the CAs present in the PEM bundle. - + - + - + + + + + + + diff --git a/docs/http/oauth.mdx b/docs/http/oauth.mdx index 5b92bf718..3b6efe8f3 100644 --- a/docs/http/oauth.mdx +++ b/docs/http/oauth.mdx @@ -6,6 +6,8 @@ import AuthnAgentCliExample from "/examples/agent-cli/http-oauth-authn.mdx"; import AuthnAgentConfigExample from "/examples/agent-config/http-oauth-authn.mdx"; import AuthnSshExample from "/examples/ssh/http-oauth-authn.mdx"; import AuthnGoSdkExample from "/examples/go-sdk/http-oauth-authn.mdx"; +import AuthnNodejsSdkExample from "/examples/nodejs-sdk/http-oauth-authn.mdx"; +import AuthnPythonSdkExample from "/examples/python-sdk/http-oauth-authn.mdx"; import AuthnRustSdkExample from "/examples/rust-sdk/http-oauth-authn.mdx"; import AuthzKubernetesExample from "/examples/k8s/http-oauth-authz.mdx"; @@ -13,6 +15,8 @@ import AuthzAgentCliExample from "/examples/agent-cli/http-oauth-authz.mdx"; import AuthzAgentConfigExample from "/examples/agent-config/http-oauth-authz.mdx"; import AuthzSshExample from "/examples/ssh/http-oauth-authz.mdx"; import AuthzGoSdkExample from "/examples/go-sdk/http-oauth-authz.mdx"; +import AuthzNodejsSdkExample from "/examples/nodejs-sdk/http-oauth-authz.mdx"; +import AuthzPythonSdkExample from "/examples/python-sdk/http-oauth-authz.mdx"; import AuthzRustSdkExample from "/examples/rust-sdk/http-oauth-authz.mdx"; import ByoAppKubernetesExample from "/examples/k8s/http-oauth-byo-app.mdx"; @@ -20,6 +24,8 @@ import ByoAppAgentCliExample from "/examples/agent-cli/http-oauth-byo-app.mdx"; import ByoAppAgentConfigExample from "/examples/agent-config/http-oauth-byo-app.mdx"; import ByoAppSshExample from "/examples/ssh/http-oauth-byo-app.mdx"; import ByoAppGoSdkExample from "/examples/go-sdk/http-oauth-byo-app.mdx"; +import ByoAppNodejsSdkExample from "/examples/nodejs-sdk/http-oauth-byo-app.mdx"; +import ByoAppPythonSdkExample from "/examples/python-sdk/http-oauth-byo-app.mdx"; import ByoAppRustSdkExample from "/examples/rust-sdk/http-oauth-byo-app.mdx"; import CustomizeScopesKubernetesExample from "/examples/k8s/http-oauth-customize-scopes.mdx"; @@ -27,6 +33,8 @@ import CustomizeScopesAgentCliExample from "/examples/agent-cli/http-oauth-custo import CustomizeScopesAgentConfigExample from "/examples/agent-config/http-oauth-customize-scopes.mdx"; import CustomizeScopesSshExample from "/examples/ssh/http-oauth-customize-scopes.mdx"; import CustomizeScopesGoSdkExample from "/examples/go-sdk/http-oauth-customize-scopes.mdx"; +import CustomizeScopesNodejsSdkExample from "/examples/nodejs-sdk/http-oauth-customize-scopes.mdx"; +import CustomizeScopesPythonSdkExample from "/examples/python-sdk/http-oauth-customize-scopes.mdx"; import CustomizeScopesRustSdkExample from "/examples/rust-sdk/http-oauth-customize-scopes.mdx"; # OAuth @@ -69,16 +77,22 @@ You can also choose other [supported providers](#supported-providers) like - + - + - + + + + + + + @@ -98,16 +112,22 @@ service. - + - + - + + + + + + + @@ -123,16 +143,22 @@ service. - + - + - + + + + + + + @@ -151,16 +177,22 @@ Users must authenticate with GitHub and grant your application the `repo` and - + - + - + + + + + + + diff --git a/docs/http/openid-connect.mdx b/docs/http/openid-connect.mdx index c0cbd26d8..6f86567c3 100644 --- a/docs/http/openid-connect.mdx +++ b/docs/http/openid-connect.mdx @@ -14,5 +14,20 @@ patience. You can consult the [OAuth module documentation](/http/oauth) in the interim. The OpenID Connect module works similarly. - ::: + +### Go SDK + +See [WithOIDC](https://pkg.go.dev/golang.ngrok.com/ngrok/config#WithOIDC) in the Go SDK docs. + +### NodeJS SDK + +See [oidc_issuer_url](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#oidc_issuer_url) in the NodeJS SDK docs. + +### Python SDK + +See [oidc](https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.oidc) in the Python SDK docs. + +### Rust SDK + +See [oidc](https://docs.rs/ngrok/latest/ngrok/config/struct.HttpTunnelBuilder.html#method.oidc) in the Rust SDK docs. diff --git a/docs/http/request-headers.mdx b/docs/http/request-headers.mdx index 86b88f2db..c508cb080 100644 --- a/docs/http/request-headers.mdx +++ b/docs/http/request-headers.mdx @@ -6,6 +6,8 @@ import AgentCliExample from "/examples/agent-cli/http-request-headers.mdx"; import AgentConfigExample from "/examples/agent-config/http-request-headers.mdx"; import SshExample from "/examples/ssh/http-request-headers.mdx"; import GoSdkExample from "/examples/go-sdk/http-request-headers.mdx"; +import NodejsSdkExample from "/examples/nodejs-sdk/http-request-headers.mdx"; +import PythonSdkExample from "/examples/python-sdk/http-request-headers.mdx"; import RustSdkExample from "/examples/rust-sdk/http-request-headers.mdx"; # Request Headers @@ -30,16 +32,22 @@ make them dynamic. - + - + - + + + + + + + diff --git a/docs/http/response-headers.mdx b/docs/http/response-headers.mdx index 227c5b930..c1115f7fb 100644 --- a/docs/http/response-headers.mdx +++ b/docs/http/response-headers.mdx @@ -6,6 +6,8 @@ import AgentCliExample from "/examples/agent-cli/http-response-headers.mdx"; import AgentConfigExample from "/examples/agent-config/http-response-headers.mdx"; import SshExample from "/examples/ssh/http-response-headers.mdx"; import GoSdkExample from "/examples/go-sdk/http-response-headers.mdx"; +import NodejsSdkExample from "/examples/nodejs-sdk/http-response-headers.mdx"; +import PythonSdkExample from "/examples/python-sdk/http-response-headers.mdx"; import RustSdkExample from "/examples/rust-sdk/http-response-headers.mdx"; # Response Headers @@ -26,16 +28,22 @@ You may [interpolate variables into header values](#variable-interpolation) to m - + - + - + + + + + + + diff --git a/docs/http/tls-termination.mdx b/docs/http/tls-termination.mdx index 5e0ebcc06..27559a9c0 100644 --- a/docs/http/tls-termination.mdx +++ b/docs/http/tls-termination.mdx @@ -5,6 +5,8 @@ import AgentCliExample from "/examples/agent-cli/http-tls-termination.mdx"; import AgentConfigExample from "/examples/agent-config/http-tls-termination.mdx"; import SshExample from "/examples/ssh/http-tls-termination.mdx"; import GoSdkExample from "/examples/go-sdk/http-tls-termination.mdx"; +import NodejsSdkExample from "/examples/nodejs-sdk/http-tls-termination.mdx"; +import PythonSdkExample from "/examples/python-sdk/http-tls-termination.mdx"; import RustSdkExample from "/examples/rust-sdk/http-tls-termination.mdx"; # TLS Termination @@ -30,16 +32,22 @@ Set the minimum supported TLS version to 1.3. - + - + - + + + + + + + diff --git a/docs/http/user-agent-filter.md b/docs/http/user-agent-filter.md index bebd2acff..44ece8675 100644 --- a/docs/http/user-agent-filter.md +++ b/docs/http/user-agent-filter.md @@ -6,6 +6,8 @@ import AgentCliExample from "/examples/agent-cli/http-user-agent-filter.mdx"; import AgentConfigExample from "/examples/agent-config/http-user-agent-filter.mdx"; import SshExample from "/examples/ssh/http-user-agent-filter.mdx"; import GoSdkExample from "/examples/go-sdk/http-user-agent-filter.mdx"; +import NodejsSdkExample from "/examples/nodejs-sdk/http-user-agent-filter.mdx"; +import PythonSdkExample from "/examples/python-sdk/http-user-agent-filter.mdx"; import RustSdkExample from "/examples/rust-sdk/http-user-agent-filter.mdx"; # User Agent Filter @@ -31,16 +33,22 @@ requests if they match the `User-Agent` header. - + - + - + + + + + + + diff --git a/docs/http/webhook-verification.mdx b/docs/http/webhook-verification.mdx index 28f582821..3467d93fc 100644 --- a/docs/http/webhook-verification.mdx +++ b/docs/http/webhook-verification.mdx @@ -5,6 +5,8 @@ import AgentCliExample from "/examples/agent-cli/http-webhook-verification.mdx"; import AgentConfigExample from "/examples/agent-config/http-webhook-verification.mdx"; import SshExample from "/examples/ssh/http-webhook-verification.mdx"; import GoSdkExample from "/examples/go-sdk/http-webhook-verification.mdx"; +import NodejsSdkExample from "/examples/nodejs-sdk/http-webhook-verification.mdx"; +import PythonSdkExample from "/examples/python-sdk/http-webhook-verification.mdx"; import RustSdkExample from "/examples/rust-sdk/http-webhook-verification.mdx"; # Webhook Verification @@ -42,16 +44,22 @@ You can also choose other [supported providers](#supported-providers) like - + - + - + + + + + + + diff --git a/docs/http/websocket-tcp-converter.mdx b/docs/http/websocket-tcp-converter.mdx index 9177e0fb8..8d98f46e1 100644 --- a/docs/http/websocket-tcp-converter.mdx +++ b/docs/http/websocket-tcp-converter.mdx @@ -5,6 +5,8 @@ import AgentCliExample from "/examples/agent-cli/http-websocket-tcp-converter.md import AgentConfigExample from "/examples/agent-config/http-websocket-tcp-converter.mdx"; import SshExample from "/examples/ssh/http-websocket-tcp-converter.mdx"; import GoSdkExample from "/examples/go-sdk/http-websocket-tcp-converter.mdx"; +import NodejsSdkExample from "/examples/nodejs-sdk/http-websocket-tcp-converter.mdx"; +import PythonSdkExample from "/examples/python-sdk/http-websocket-tcp-converter.mdx"; import RustSdkExample from "/examples/rust-sdk/http-websocket-tcp-converter.mdx"; # Websocket TCP Converter @@ -28,16 +30,22 @@ responses. - + - + - + + + + + + + diff --git a/docs/network-edge/gslb.mdx b/docs/network-edge/gslb.mdx index 2df0fa1f3..7747ea761 100644 --- a/docs/network-edge/gslb.mdx +++ b/docs/network-edge/gslb.mdx @@ -5,6 +5,8 @@ import ExplicitRegionAgentCliExample from "/examples/agent-cli/explicit-region.m import ExplicitRegionAgentConfigExample from "/examples/agent-config/explicit-region.mdx"; import ExplicitRegionSshExample from "/examples/ssh/explicit-region.mdx"; import ExplicitRegionGoSdkExample from "/examples/go-sdk/explicit-region.mdx"; +import ExplicitRegionNodejsSdkExample from "/examples/nodejs-sdk/explicit-region.mdx"; +import ExplicitRegionPythonSdkExample from "/examples/python-sdk/explicit-region.mdx"; import ExplicitRegionRustSdkExample from "/examples/rust-sdk/explicit-region.mdx"; import ExplicitRegionKubernetesExample from "/examples/k8s/explicit-region.mdx"; @@ -178,16 +180,22 @@ do so with the following configuration: - + - + - + + + + + + + diff --git a/docs/tcp/index.mdx b/docs/tcp/index.mdx index 7a6947b30..23621c07d 100644 --- a/docs/tcp/index.mdx +++ b/docs/tcp/index.mdx @@ -12,6 +12,8 @@ import RandomAgentCliExample from "/examples/agent-cli/tcp-random.mdx"; import RandomAgentConfigExample from "/examples/agent-config/tcp-random.mdx"; import RandomSshExample from "/examples/ssh/tcp-random.mdx"; import RandomGoSdkExample from "/examples/go-sdk/tcp-random.mdx"; +import RandomNodejsSdkExample from "/examples/nodejs-sdk/tcp-random.mdx"; +import RandomPythonSdkExample from "/examples/python-sdk/tcp-random.mdx"; import RandomRustSdkExample from "/examples/rust-sdk/tcp-random.mdx"; import FixedKubernetesExample from "/examples/k8s/tcp-fixed.mdx"; @@ -19,6 +21,8 @@ import FixedAgentCliExample from "/examples/agent-cli/tcp-fixed.mdx"; import FixedAgentConfigExample from "/examples/agent-config/tcp-fixed.mdx"; import FixedSshExample from "/examples/ssh/tcp-fixed.mdx"; import FixedGoSdkExample from "/examples/go-sdk/tcp-fixed.mdx"; +import FixedNodejsSdkExample from "/examples/nodejs-sdk/tcp-fixed.mdx"; +import FixedPythonSdkExample from "/examples/python-sdk/tcp-fixed.mdx"; import FixedRustSdkExample from "/examples/rust-sdk/tcp-fixed.mdx"; import NonLocalKubernetesExample from "/examples/k8s/tcp-nonlocal.mdx"; @@ -26,6 +30,8 @@ import NonLocalAgentCliExample from "/examples/agent-cli/tcp-nonlocal.mdx"; import NonLocalAgentConfigExample from "/examples/agent-config/tcp-nonlocal.mdx"; import NonLocalSshExample from "/examples/ssh/tcp-nonlocal.mdx"; import NonLocalGoSdkExample from "/examples/go-sdk/tcp-nonlocal.mdx"; +import NonLocalNodejsSdkExample from "/examples/nodejs-sdk/tcp-nonlocal.mdx"; +import NonLocalPythonSdkExample from "/examples/python-sdk/tcp-nonlocal.mdx"; import NonLocalRustSdkExample from "/examples/rust-sdk/tcp-nonlocal.mdx"; import ProxyProtoKubernetesExample from "/examples/k8s/tcp-proxyproto.mdx"; @@ -33,6 +39,8 @@ import ProxyProtoAgentCliExample from "/examples/agent-cli/tcp-proxyproto.mdx"; import ProxyProtoAgentConfigExample from "/examples/agent-config/tcp-proxyproto.mdx"; import ProxyProtoSshExample from "/examples/ssh/tcp-proxyproto.mdx"; import ProxyProtoGoSdkExample from "/examples/go-sdk/tcp-proxyproto.mdx"; +import ProxyProtoNodejsSdkExample from "/examples/nodejs-sdk/tcp-proxyproto.mdx"; +import ProxyProtoPythonSdkExample from "/examples/python-sdk/tcp-proxyproto.mdx"; import ProxyProtoRustSdkExample from "/examples/rust-sdk/tcp-proxyproto.mdx"; # TCP Endpoints @@ -65,16 +73,22 @@ Listen on a random TCP address. - + - + - + + + + + + + @@ -93,16 +107,22 @@ address ahead of time, see [TCP Addresses](/network-edge/domains-and-tcp-address - + - + - + + + + + + + @@ -121,16 +141,22 @@ Forward to a non-local Postgres instance listening on your network at - + - + - + + + + + + + @@ -149,16 +175,22 @@ the original client IP address to your upstream service. - + - + - + + + + + + + diff --git a/docs/tcp/ip-restrictions.mdx b/docs/tcp/ip-restrictions.mdx index b752cb599..e6685562b 100644 --- a/docs/tcp/ip-restrictions.mdx +++ b/docs/tcp/ip-restrictions.mdx @@ -5,6 +5,8 @@ import AgentCliExample from "/examples/agent-cli/tcp-ip-restrictions.mdx"; import AgentConfigExample from "/examples/agent-config/tcp-ip-restrictions.mdx"; import SshExample from "/examples/ssh/tcp-ip-restrictions.mdx"; import GoSdkExample from "/examples/go-sdk/tcp-ip-restrictions.mdx"; +import NodejsSdkExample from "/examples/nodejs-sdk/tcp-ip-restrictions.mdx"; +import PythonSdkExample from "/examples/python-sdk/tcp-ip-restrictions.mdx"; import RustSdkExample from "/examples/rust-sdk/tcp-ip-restrictions.mdx"; # IP Restrictions @@ -29,16 +31,22 @@ Allow TCP connections from `110.0.0.0/8` and `220.12.0.0/16` but not from - + - + - + + + + + + + diff --git a/docs/tls/index.mdx b/docs/tls/index.mdx index a960d3975..0be5a06b6 100644 --- a/docs/tls/index.mdx +++ b/docs/tls/index.mdx @@ -12,6 +12,8 @@ import AtAgentAgentCliExample from "/examples/agent-cli/tls-terminate-at-agent.m import AtAgentAgentConfigExample from "/examples/agent-config/tls-terminate-at-agent.mdx"; import AtAgentSshExample from "/examples/ssh/tls-terminate-at-agent.mdx"; import AtAgentGoSdkExample from "/examples/go-sdk/tls-terminate-at-agent.mdx"; +import AtAgentNodejsSdkExample from "/examples/nodejs-sdk/tls-terminate-at-agent.mdx"; +import AtAgentPythonSdkExample from "/examples/python-sdk/tls-terminate-at-agent.mdx"; import AtAgentRustSdkExample from "/examples/rust-sdk/tls-terminate-at-agent.mdx"; import AtUpstreamKubernetesExample from "/examples/k8s/tls-terminate-at-upstream.mdx"; @@ -19,6 +21,8 @@ import AtUpstreamAgentCliExample from "/examples/agent-cli/tls-terminate-at-upst import AtUpstreamAgentConfigExample from "/examples/agent-config/tls-terminate-at-upstream.mdx"; import AtUpstreamSshExample from "/examples/ssh/tls-terminate-at-upstream.mdx"; import AtUpstreamGoSdkExample from "/examples/go-sdk/tls-terminate-at-upstream.mdx"; +import AtUpstreamNodejsSdkExample from "/examples/nodejs-sdk/tls-terminate-at-upstream.mdx"; +import AtUpstreamPythonSdkExample from "/examples/python-sdk/tls-terminate-at-upstream.mdx"; import AtUpstreamRustSdkExample from "/examples/rust-sdk/tls-terminate-at-upstream.mdx"; import CustomDomainKubernetesExample from "/examples/k8s/tls-terminate-at-edge-custom-domain.mdx"; @@ -26,6 +30,8 @@ import CustomDomainAgentCliExample from "/examples/agent-cli/tls-terminate-at-ed import CustomDomainAgentConfigExample from "/examples/agent-config/tls-terminate-at-edge-custom-domain.mdx"; import CustomDomainSshExample from "/examples/ssh/tls-terminate-at-edge-custom-domain.mdx"; import CustomDomainGoSdkExample from "/examples/go-sdk/tls-terminate-at-edge-custom-domain.mdx"; +import CustomDomainNodejsSdkExample from "/examples/nodejs-sdk/tls-terminate-at-edge-custom-domain.mdx"; +import CustomDomainPythonSdkExample from "/examples/python-sdk/tls-terminate-at-edge-custom-domain.mdx"; import CustomDomainRustSdkExample from "/examples/rust-sdk/tls-terminate-at-edge-custom-domain.mdx"; import ReencryptUpstreamKubernetesExample from "/examples/k8s/tls-reencrypt-upstream.mdx"; @@ -33,6 +39,8 @@ import ReencryptUpstreamAgentCliExample from "/examples/agent-cli/tls-reencrypt- import ReencryptUpstreamAgentConfigExample from "/examples/agent-config/tls-reencrypt-upstream.mdx"; import ReencryptUpstreamSshExample from "/examples/ssh/tls-reencrypt-upstream.mdx"; import ReencryptUpstreamGoSdkExample from "/examples/go-sdk/tls-reencrypt-upstream.mdx"; +import ReencryptUpstreamNodejsSdkExample from "/examples/nodejs-sdk/tls-reencrypt-upstream.mdx"; +import ReencryptUpstreamPythonSdkExample from "/examples/python-sdk/tls-reencrypt-upstream.mdx"; import ReencryptUpstreamRustSdkExample from "/examples/rust-sdk/tls-reencrypt-upstream.mdx"; import ProxyProtoKubernetesExample from "/examples/k8s/tls-proxyproto.mdx"; @@ -40,6 +48,8 @@ import ProxyProtoAgentCliExample from "/examples/agent-cli/tls-proxyproto.mdx"; import ProxyProtoAgentConfigExample from "/examples/agent-config/tls-proxyproto.mdx"; import ProxyProtoSshExample from "/examples/ssh/tls-proxyproto.mdx"; import ProxyProtoGoSdkExample from "/examples/go-sdk/tls-proxyproto.mdx"; +import ProxyProtoNodejsSdkExample from "/examples/nodejs-sdk/tls-proxyproto.mdx"; +import ProxyProtoPythonSdkExample from "/examples/python-sdk/tls-proxyproto.mdx"; import ProxyProtoRustSdkExample from "/examples/rust-sdk/tls-proxyproto.mdx"; # TLS Endpoints @@ -75,16 +85,22 @@ Endpoint](/http/). - + - + - + + + + + + + @@ -102,16 +118,22 @@ See [Zero-Knowledge TLS](/tls/tls-termination#zero-knowledge-tls) for additional - + - + - + + + + + + + @@ -129,16 +151,22 @@ See [Zero-Knowledge TLS at the Agent](/tls/tls-termination#zero-knowledge-tls-at - + - + - + + + + + + + @@ -160,16 +188,22 @@ ngrok tls tls://localhost:443 --terminate-at=edge ``` - + - + - + + + + + + + @@ -188,16 +222,22 @@ the original client IP address to your upstream service. - + - + - + + + + + + + diff --git a/docs/tls/ip-restrictions.mdx b/docs/tls/ip-restrictions.mdx index fb2d0a9fb..6be9c3c93 100644 --- a/docs/tls/ip-restrictions.mdx +++ b/docs/tls/ip-restrictions.mdx @@ -5,6 +5,8 @@ import AgentCliExample from "/examples/agent-cli/tls-ip-restrictions.mdx"; import AgentConfigExample from "/examples/agent-config/tls-ip-restrictions.mdx"; import SshExample from "/examples/ssh/tls-ip-restrictions.mdx"; import GoSdkExample from "/examples/go-sdk/tls-ip-restrictions.mdx"; +import NodejsSdkExample from "/examples/nodejs-sdk/tls-ip-restrictions.mdx"; +import PythonSdkExample from "/examples/python-sdk/tls-ip-restrictions.mdx"; import RustSdkExample from "/examples/rust-sdk/tls-ip-restrictions.mdx"; # IP Restrictions @@ -29,16 +31,22 @@ Allow TCP connections from `110.0.0.0/8` and `220.12.0.0/16` but not from - + - + - + + + + + + + diff --git a/docs/tls/mutual-tls.mdx b/docs/tls/mutual-tls.mdx index 27d9084aa..2d666dd8d 100644 --- a/docs/tls/mutual-tls.mdx +++ b/docs/tls/mutual-tls.mdx @@ -6,6 +6,8 @@ import AtEdgeAgentCliExample from "/examples/agent-cli/tls-mtls-at-edge.mdx"; import AtEdgeAgentConfigExample from "/examples/agent-config/tls-mtls-at-edge.mdx"; import AtEdgeSshExample from "/examples/ssh/tls-mtls-at-edge.mdx"; import AtEdgeGoSdkExample from "/examples/go-sdk/tls-mtls-at-edge.mdx"; +import AtEdgeNodejsSdkExample from "/examples/nodejs-sdk/tls-mtls-at-edge.mdx"; +import AtEdgePythonSdkExample from "/examples/python-sdk/tls-mtls-at-edge.mdx"; import AtEdgeRustSdkExample from "/examples/rust-sdk/tls-mtls-at-edge.mdx"; import AtAgentKubernetesExample from "/examples/k8s/tls-mtls-at-agent.mdx"; @@ -13,6 +15,8 @@ import AtAgentAgentCliExample from "/examples/agent-cli/tls-mtls-at-agent.mdx"; import AtAgentAgentConfigExample from "/examples/agent-config/tls-mtls-at-agent.mdx"; import AtAgentSshExample from "/examples/ssh/tls-mtls-at-agent.mdx"; import AtAgentGoSdkExample from "/examples/go-sdk/tls-mtls-at-agent.mdx"; +import AtAgentNodejsSdkExample from "/examples/nodejs-sdk/tls-mtls-at-agent.mdx"; +import AtAgentPythonSdkExample from "/examples/python-sdk/tls-mtls-at-agent.mdx"; import AtAgentRustSdkExample from "/examples/rust-sdk/tls-mtls-at-agent.mdx"; # Mutual TLS @@ -45,16 +49,22 @@ CAs present in the PEM bundle. - + - + - + + + + + + + @@ -73,16 +83,22 @@ TLS](/tls/tls-termination#zero-knowledge-tls) end-to-end encryption. - + - + - + + + + + + + diff --git a/docs/tls/tls-termination.mdx b/docs/tls/tls-termination.mdx index df17b68d8..27fe66eab 100644 --- a/docs/tls/tls-termination.mdx +++ b/docs/tls/tls-termination.mdx @@ -6,6 +6,8 @@ import AtEdgeAgentCliExample from "/examples/agent-cli/tls-terminate-at-edge.mdx import AtEdgeAgentConfigExample from "/examples/agent-config/tls-terminate-at-edge.mdx"; import AtEdgeSshExample from "/examples/ssh/tls-terminate-at-edge.mdx"; import AtEdgeGoSdkExample from "/examples/go-sdk/tls-terminate-at-edge.mdx"; +import AtEdgeNodejsSdkExample from "/examples/nodejs-sdk/tls-terminate-at-edge.mdx"; +import AtEdgePythonSdkExample from "/examples/python-sdk/tls-terminate-at-edge.mdx"; import AtEdgeRustSdkExample from "/examples/rust-sdk/tls-terminate-at-edge.mdx"; import CustomCertKubernetesExample from "/examples/k8s/tls-terminate-at-edge-custom-cert.mdx"; @@ -13,6 +15,8 @@ import CustomCertAgentCliExample from "/examples/agent-cli/tls-terminate-at-edge import CustomCertAgentConfigExample from "/examples/agent-config/tls-terminate-at-edge-custom-cert.mdx"; import CustomCertSshExample from "/examples/ssh/tls-terminate-at-edge-custom-cert.mdx"; import CustomCertGoSdkExample from "/examples/go-sdk/tls-terminate-at-edge-custom-cert.mdx"; +import CustomCertNodejsSdkExample from "/examples/nodejs-sdk/tls-terminate-at-edge-custom-cert.mdx"; +import CustomCertPythonSdkExample from "/examples/python-sdk/tls-terminate-at-edge-custom-cert.mdx"; import CustomCertRustSdkExample from "/examples/rust-sdk/tls-terminate-at-edge-custom-cert.mdx"; import AtAgentKubernetesExample from "/examples/k8s/tls-terminate-at-agent.mdx"; @@ -20,6 +24,8 @@ import AtAgentAgentCliExample from "/examples/agent-cli/tls-terminate-at-agent.m import AtAgentAgentConfigExample from "/examples/agent-config/tls-terminate-at-agent.mdx"; import AtAgentSshExample from "/examples/ssh/tls-terminate-at-agent.mdx"; import AtAgentGoSdkExample from "/examples/go-sdk/tls-terminate-at-agent.mdx"; +import AtAgentNodejsSdkExample from "/examples/nodejs-sdk/tls-terminate-at-agent.mdx"; +import AtAgentPythonSdkExample from "/examples/python-sdk/tls-terminate-at-agent.mdx"; import AtAgentRustSdkExample from "/examples/rust-sdk/tls-terminate-at-agent.mdx"; import AtUpstreamKubernetesExample from "/examples/k8s/tls-terminate-at-upstream.mdx"; @@ -27,6 +33,8 @@ import AtUpstreamAgentCliExample from "/examples/agent-cli/tls-terminate-at-upst import AtUpstreamAgentConfigExample from "/examples/agent-config/tls-terminate-at-upstream.mdx"; import AtUpstreamSshExample from "/examples/ssh/tls-terminate-at-upstream.mdx"; import AtUpstreamGoSdkExample from "/examples/go-sdk/tls-terminate-at-upstream.mdx"; +import AtUpstreamNodejsSdkExample from "/examples/nodejs-sdk/tls-terminate-at-upstream.mdx"; +import AtUpstreamPythonSdkExample from "/examples/python-sdk/tls-terminate-at-upstream.mdx"; import AtUpstreamRustSdkExample from "/examples/rust-sdk/tls-terminate-at-upstream.mdx"; # TLS Termination @@ -62,16 +70,22 @@ circumstances: - + - + - + + + + + + + @@ -87,16 +101,22 @@ circumstances: - + - + - + + + + + + + @@ -112,16 +132,22 @@ circumstances: - + - + - + + + + + + + @@ -137,16 +163,22 @@ circumstances: - + - + - + + + + + + + diff --git a/examples/nodejs-sdk/custom-agent-ingress.mdx b/examples/nodejs-sdk/custom-agent-ingress.mdx new file mode 100644 index 000000000..ab5721e99 --- /dev/null +++ b/examples/nodejs-sdk/custom-agent-ingress.mdx @@ -0,0 +1,20 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); + +(async function () { + const session = await new ngrok.SessionBuilder() + .authtokenFromEnv() + .serverAddr("us.agents.example.com:443") + .connect(); + + const listener = await session + .httpEndpoint() + .listenAndForward("http://localhost:8080"); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/classes/SessionBuilder.html#serverAddr](https://ngrok.github.io/ngrok-nodejs/classes/SessionBuilder.html#serverAddr) diff --git a/examples/nodejs-sdk/explicit-region.mdx b/examples/nodejs-sdk/explicit-region.mdx new file mode 100644 index 000000000..dd7d992ee --- /dev/null +++ b/examples/nodejs-sdk/explicit-region.mdx @@ -0,0 +1,20 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); + +(async function () { + const session = await new ngrok.SessionBuilder() + .authtokenFromEnv() + .serverAddr("connect.eu.ngrok-agent.com:443") + .connect(); + + const listener = await session + .httpEndpoint() + .listenAndForward("http://localhost:8080"); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/classes/SessionBuilder.html#serverAddr](https://ngrok.github.io/ngrok-nodejs/classes/SessionBuilder.html#serverAddr) diff --git a/examples/nodejs-sdk/http-basic-auth.mdx b/examples/nodejs-sdk/http-basic-auth.mdx new file mode 100644 index 000000000..32f79c454 --- /dev/null +++ b/examples/nodejs-sdk/http-basic-auth.mdx @@ -0,0 +1,18 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); + +(async function () { + const listener = await ngrok.connect({ + addr: 8080, + authtoken_from_env: true, + basic_auth: ["username1:password1", "username2:password2"], + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#basic_auth](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#basic_auth) +- [https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#basicAuth](https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#basicAuth) diff --git a/examples/nodejs-sdk/http-branded-domain.mdx b/examples/nodejs-sdk/http-branded-domain.mdx new file mode 100644 index 000000000..e74db7af7 --- /dev/null +++ b/examples/nodejs-sdk/http-branded-domain.mdx @@ -0,0 +1,18 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); + +(async function () { + const listener = await ngrok.connect({ + addr: 8080, + authtoken_from_env: true, + domain: "example.ngrok.app", + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#domain](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#domain) +- [https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#domain](https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#domain) diff --git a/examples/nodejs-sdk/http-circuit-breaker.mdx b/examples/nodejs-sdk/http-circuit-breaker.mdx new file mode 100644 index 000000000..565b41f5b --- /dev/null +++ b/examples/nodejs-sdk/http-circuit-breaker.mdx @@ -0,0 +1,18 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); + +(async function () { + const listener = await ngrok.connect({ + addr: 8080, + authtoken_from_env: true, + circuit_breaker: 0.5, + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#circuit_breaker](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#circuit_breaker) +- [https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#circuitBreaker](https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#circuitBreaker) diff --git a/examples/nodejs-sdk/http-compression.mdx b/examples/nodejs-sdk/http-compression.mdx new file mode 100644 index 000000000..5551334b6 --- /dev/null +++ b/examples/nodejs-sdk/http-compression.mdx @@ -0,0 +1,18 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); + +(async function () { + const listener = await ngrok.connect({ + addr: 8080, + authtoken_from_env: true, + compression: true, + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#compression](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#compression) +- [https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#compression](https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#compression) diff --git a/examples/nodejs-sdk/http-fileserver-abs-path.mdx b/examples/nodejs-sdk/http-fileserver-abs-path.mdx new file mode 100644 index 000000000..c8621b37e --- /dev/null +++ b/examples/nodejs-sdk/http-fileserver-abs-path.mdx @@ -0,0 +1,5 @@ +:::info + +Serving directory files is not supported in the NodeJS SDK. + +::: diff --git a/examples/nodejs-sdk/http-fileserver-windows.mdx b/examples/nodejs-sdk/http-fileserver-windows.mdx new file mode 100644 index 000000000..c8621b37e --- /dev/null +++ b/examples/nodejs-sdk/http-fileserver-windows.mdx @@ -0,0 +1,5 @@ +:::info + +Serving directory files is not supported in the NodeJS SDK. + +::: diff --git a/examples/nodejs-sdk/http-fileserver-working-dir.mdx b/examples/nodejs-sdk/http-fileserver-working-dir.mdx new file mode 100644 index 000000000..c8621b37e --- /dev/null +++ b/examples/nodejs-sdk/http-fileserver-working-dir.mdx @@ -0,0 +1,5 @@ +:::info + +Serving directory files is not supported in the NodeJS SDK. + +::: diff --git a/examples/nodejs-sdk/http-forward-https.mdx b/examples/nodejs-sdk/http-forward-https.mdx new file mode 100644 index 000000000..5da48ab31 --- /dev/null +++ b/examples/nodejs-sdk/http-forward-https.mdx @@ -0,0 +1,17 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); + +(async function () { + const listener = await ngrok.connect({ + addr: "https://localhost:8443", + authtoken_from_env: true, + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#addr](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#addr) +- [https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#listenAndForward](https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#listenAndForward) diff --git a/examples/nodejs-sdk/http-ip-restrictions.mdx b/examples/nodejs-sdk/http-ip-restrictions.mdx new file mode 100644 index 000000000..3793d825c --- /dev/null +++ b/examples/nodejs-sdk/http-ip-restrictions.mdx @@ -0,0 +1,21 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); + +(async function () { + const listener = await ngrok.connect({ + addr: 8080, + authtoken_from_env: true, + ip_restriction_allow_cidrs: ["110.0.0.0/8", "220.12.0.0/16"], + ip_restriction_deny_cidrs: "110.2.3.4/32", + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#ip_restriction_allow_cidrs](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#ip_restriction_allow_cidrs) +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#ip_restriction_deny_cidrs](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#ip_restriction_deny_cidrs) +- [https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#allowCidr](https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#allowCidr) +- [https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#denyCidr](https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#denyCidr) diff --git a/examples/nodejs-sdk/http-mutual-tls.mdx b/examples/nodejs-sdk/http-mutual-tls.mdx new file mode 100644 index 000000000..8247defe4 --- /dev/null +++ b/examples/nodejs-sdk/http-mutual-tls.mdx @@ -0,0 +1,19 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); +const fs = require("fs"); + +(async function () { + const listener = await ngrok.connect({ + addr: 8080, + authtoken_from_env: true, + mutual_tls_cas: [fs.readFileSync("/path/to/cas.pem", "utf8")], + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#mutual_tls_cas](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#mutual_tls_cas) +- [https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#mutualTlsca](https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#mutualTlsca) diff --git a/examples/nodejs-sdk/http-nonlocal.mdx b/examples/nodejs-sdk/http-nonlocal.mdx new file mode 100644 index 000000000..7b3466856 --- /dev/null +++ b/examples/nodejs-sdk/http-nonlocal.mdx @@ -0,0 +1,17 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); + +(async function () { + const listener = await ngrok.connect({ + addr: "192.168.1.2:80", + authtoken_from_env: true, + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#addr](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#addr) +- [https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#listenAndForward](https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#listenAndForward) diff --git a/examples/nodejs-sdk/http-oauth-authn.mdx b/examples/nodejs-sdk/http-oauth-authn.mdx new file mode 100644 index 000000000..c3cef23f8 --- /dev/null +++ b/examples/nodejs-sdk/http-oauth-authn.mdx @@ -0,0 +1,18 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); + +(async function () { + const listener = await ngrok.connect({ + addr: 8080, + authtoken_from_env: true, + oauth_provider: "google", + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#oauth_provider](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#oauth_provider) +- [https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#oauth](https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#oauth) diff --git a/examples/nodejs-sdk/http-oauth-authz.mdx b/examples/nodejs-sdk/http-oauth-authz.mdx new file mode 100644 index 000000000..e073e049a --- /dev/null +++ b/examples/nodejs-sdk/http-oauth-authz.mdx @@ -0,0 +1,21 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); + +(async function () { + const listener = await ngrok.connect({ + addr: 8080, + authtoken_from_env: true, + oauth_provider: "google", + oauth_allow_emails: "kate.libby@gmail.com", + oauth_allow_domains: "acme.org", + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#oauth_allow_domains](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#oauth_allow_domains) +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#oauth_allow_emails](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#oauth_allow_emails) +- [https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#oauth](https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#oauth) diff --git a/examples/nodejs-sdk/http-oauth-byo-app.mdx b/examples/nodejs-sdk/http-oauth-byo-app.mdx new file mode 100644 index 000000000..75733b1b7 --- /dev/null +++ b/examples/nodejs-sdk/http-oauth-byo-app.mdx @@ -0,0 +1,21 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); + +(async function () { + const listener = await ngrok.connect({ + addr: 8080, + authtoken_from_env: true, + oauth_provider: "microsoft", + oauth_client_id: "{client id}", + oauth_client_secret: "{client secret}", + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#oauth_client_id](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#oauth_client_id) +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#oauth_client_secret](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#oauth_client_secret) +- [https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#oauth](https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#oauth) diff --git a/examples/nodejs-sdk/http-oauth-customize-scopes.mdx b/examples/nodejs-sdk/http-oauth-customize-scopes.mdx new file mode 100644 index 000000000..0ada8df6d --- /dev/null +++ b/examples/nodejs-sdk/http-oauth-customize-scopes.mdx @@ -0,0 +1,21 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); + +(async function () { + + const listener = await ngrok.connect({ addr: 8080, authtoken_from_env: true, + oauth_provider: "github", + oauth_client_id: "{client id}", + oauth_client_secret: "{client secret}"}, + oauth_scopes: ["repo", "user"]); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#oauth_client_id](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#oauth_client_id) +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#oauth_client_secret](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#oauth_client_secret) +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#oauth_scopes](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#oauth_scopes) +- [https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#oauth](https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#oauth) diff --git a/examples/nodejs-sdk/http-random.mdx b/examples/nodejs-sdk/http-random.mdx new file mode 100644 index 000000000..0d9b6c88e --- /dev/null +++ b/examples/nodejs-sdk/http-random.mdx @@ -0,0 +1,18 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); + +(async function () { + const listener = await ngrok.connect({ + addr: 8080, + authtoken_from_env: true, + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html](https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html) +- [https://ngrok.github.io/ngrok-nodejs/classes/Session.html#httpEndpoint](https://ngrok.github.io/ngrok-nodejs/classes/Session.html#httpEndpoint) +- [https://ngrok.github.io/ngrok-nodejs/functions/connect.html](https://ngrok.github.io/ngrok-nodejs/functions/connect.html) diff --git a/examples/nodejs-sdk/http-request-headers.mdx b/examples/nodejs-sdk/http-request-headers.mdx new file mode 100644 index 000000000..8559c6d80 --- /dev/null +++ b/examples/nodejs-sdk/http-request-headers.mdx @@ -0,0 +1,21 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); + +(async function () { + const listener = await ngrok.connect({ + addr: 8080, + authtoken_from_env: true, + request_header_add: ["is-ngrok:1", "country:${.ngrok.geo.country_code}"], + request_header_remove: "referrer", + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#request_header_add](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#request_header_add) +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#request_header_remove](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#request_header_remove) +- [https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#requestHeader](https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#requestHeader) +- [https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#removeRequestHeader](https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#removeRequestHeader) diff --git a/examples/nodejs-sdk/http-response-headers.mdx b/examples/nodejs-sdk/http-response-headers.mdx new file mode 100644 index 000000000..5b356e98d --- /dev/null +++ b/examples/nodejs-sdk/http-response-headers.mdx @@ -0,0 +1,24 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); + +(async function () { + const listener = await ngrok.connect({ + addr: 8080, + authtoken_from_env: true, + response_header_add: [ + "content-security-policy:self", + "dial-duration:${.backend.dial_duration}", + ], + response_header_remove: "internal-trace-id", + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#response_header_add](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#response_header_add) +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#response_header_remove](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#response_header_remove) +- [https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#responseHeader](https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#responseHeader) +- [https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#removeResponseHeader](https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#removeResponseHeader) diff --git a/examples/nodejs-sdk/http-rewrite-host-header.mdx b/examples/nodejs-sdk/http-rewrite-host-header.mdx new file mode 100644 index 000000000..bcff92d89 --- /dev/null +++ b/examples/nodejs-sdk/http-rewrite-host-header.mdx @@ -0,0 +1,18 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); + +(async function () { + const listener = await ngrok.connect({ + addr: 8080, + authtoken_from_env: true, + request_header_add: "host:localhost", + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#request_header_add](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#request_header_add) +- [https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#requestHeader](https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#requestHeader) diff --git a/examples/nodejs-sdk/http-schemes.mdx b/examples/nodejs-sdk/http-schemes.mdx new file mode 100644 index 000000000..9c0405a96 --- /dev/null +++ b/examples/nodejs-sdk/http-schemes.mdx @@ -0,0 +1,17 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); + +(async function () { + const listener = await ngrok.connect({ + addr: 8080, + authtoken_from_env: true, + schemes: "http", + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#schemes](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#schemes) diff --git a/examples/nodejs-sdk/http-static-domain.mdx b/examples/nodejs-sdk/http-static-domain.mdx new file mode 100644 index 000000000..e74db7af7 --- /dev/null +++ b/examples/nodejs-sdk/http-static-domain.mdx @@ -0,0 +1,18 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); + +(async function () { + const listener = await ngrok.connect({ + addr: 8080, + authtoken_from_env: true, + domain: "example.ngrok.app", + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#domain](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#domain) +- [https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#domain](https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#domain) diff --git a/examples/nodejs-sdk/http-tls-termination.mdx b/examples/nodejs-sdk/http-tls-termination.mdx new file mode 100644 index 000000000..92ba4f369 --- /dev/null +++ b/examples/nodejs-sdk/http-tls-termination.mdx @@ -0,0 +1,5 @@ +:::info + +TLS termination is not configurable via the NodeJS SDK + +::: diff --git a/examples/nodejs-sdk/http-user-agent-filter.mdx b/examples/nodejs-sdk/http-user-agent-filter.mdx new file mode 100644 index 000000000..a5380b894 --- /dev/null +++ b/examples/nodejs-sdk/http-user-agent-filter.mdx @@ -0,0 +1,21 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); + +(async function () { + const listener = await ngrok.connect({ + addr: 8080, + authtoken_from_env: true, + allow_user_agent: "foo/(d)+", + deny_user_agent: "bar/(d)+", + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#allow_user_agent](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#allow_user_agent) +- [https://docs.rs/ngrok/latest/ngrok/config/struct.HttpTunnelBuilder.html#method.deny_ua](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#deny_user_agent) +- [https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#allowUserAgent](https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#allowUserAgent) +- [https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#denyUserAgent](https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#denyUserAgent) diff --git a/examples/nodejs-sdk/http-webhook-verification.mdx b/examples/nodejs-sdk/http-webhook-verification.mdx new file mode 100644 index 000000000..39b656747 --- /dev/null +++ b/examples/nodejs-sdk/http-webhook-verification.mdx @@ -0,0 +1,20 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); + +(async function () { + const listener = await ngrok.connect({ + addr: 8080, + authtoken_from_env: true, + verify_webhook_provider: "twilio", + verify_webhook_secret: "{twilio signing secret}", + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#verify_webhook_provider](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#verify_webhook_provider) +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#verify_webhook_secret](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#verify_webhook_secret) +- [https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#webhookVerification](https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#webhookVerification) diff --git a/examples/nodejs-sdk/http-websocket-tcp-converter.mdx b/examples/nodejs-sdk/http-websocket-tcp-converter.mdx new file mode 100644 index 000000000..2f322fbf3 --- /dev/null +++ b/examples/nodejs-sdk/http-websocket-tcp-converter.mdx @@ -0,0 +1,18 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); + +(async function () { + const listener = await ngrok.connect({ + addr: 8080, + authtoken_from_env: true, + websocket_tcp_converter: true, + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#websocket_tcp_converter](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#websocket_tcp_converter) +- [https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#websocketTcpConversion](https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#websocketTcpConversion) diff --git a/examples/nodejs-sdk/http-wildcard-domain.mdx b/examples/nodejs-sdk/http-wildcard-domain.mdx new file mode 100644 index 000000000..84b68f036 --- /dev/null +++ b/examples/nodejs-sdk/http-wildcard-domain.mdx @@ -0,0 +1,18 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); + +(async function () { + const listener = await ngrok.connect({ + addr: 8080, + authtoken_from_env: true, + domain: "*.example.com", + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#domain](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#domain) +- [https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#domain](https://ngrok.github.io/ngrok-nodejs/classes/HttpListenerBuilder.html#domain) diff --git a/examples/nodejs-sdk/tcp-fixed.mdx b/examples/nodejs-sdk/tcp-fixed.mdx new file mode 100644 index 000000000..6071f9e1b --- /dev/null +++ b/examples/nodejs-sdk/tcp-fixed.mdx @@ -0,0 +1,19 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); + +(async function () { + const listener = await ngrok.connect({ + addr: 8080, + authtoken_from_env: true, + proto: "tcp", + remote_addr: "1.tcp.eu.ngrok.io:12345", + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#remote_addr](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#remote_addr) +- [https://ngrok.github.io/ngrok-nodejs/classes/TcpListenerBuilder.html#remoteAddr](https://ngrok.github.io/ngrok-nodejs/classes/TcpListenerBuilder.html#remoteAddr) diff --git a/examples/nodejs-sdk/tcp-ip-restrictions.mdx b/examples/nodejs-sdk/tcp-ip-restrictions.mdx new file mode 100644 index 000000000..530358766 --- /dev/null +++ b/examples/nodejs-sdk/tcp-ip-restrictions.mdx @@ -0,0 +1,22 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); + +(async function () { + const listener = await ngrok.connect({ + addr: 8080, + authtoken_from_env: true, + proto: "tcp", + ip_restriction_allow_cidrs: ["110.0.0.0/8", "220.12.0.0/16"], + ip_restriction_deny_cidrs: "110.2.3.4/32", + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#ip_restriction_allow_cidrs](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#ip_restriction_allow_cidrs) +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#ip_restriction_deny_cidrs](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#ip_restriction_deny_cidrs) +- [https://ngrok.github.io/ngrok-nodejs/classes/TcpListenerBuilder.html#allowCidr](https://ngrok.github.io/ngrok-nodejs/classes/TcpListenerBuilder.html#allowCidr) +- [https://ngrok.github.io/ngrok-nodejs/classes/TcpListenerBuilder.html#denyCidr](https://ngrok.github.io/ngrok-nodejs/classes/TcpListenerBuilder.html#denyCidr) diff --git a/examples/nodejs-sdk/tcp-nonlocal.mdx b/examples/nodejs-sdk/tcp-nonlocal.mdx new file mode 100644 index 000000000..d7558b983 --- /dev/null +++ b/examples/nodejs-sdk/tcp-nonlocal.mdx @@ -0,0 +1,18 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); + +(async function () { + const listener = await ngrok.connect({ + addr: "192.168.1.2:5432", + authtoken_from_env: true, + proto: "tcp", + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#addr](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#addr) +- [https://ngrok.github.io/ngrok-nodejs/classes/TcpListenerBuilder.html#listenAndForward](https://ngrok.github.io/ngrok-nodejs/classes/TcpListenerBuilder.html#listenAndForward) diff --git a/examples/nodejs-sdk/tcp-proxyproto.mdx b/examples/nodejs-sdk/tcp-proxyproto.mdx new file mode 100644 index 000000000..0f2d34068 --- /dev/null +++ b/examples/nodejs-sdk/tcp-proxyproto.mdx @@ -0,0 +1,19 @@ +```rust +use ngrok::prelude::*; + +(async function () { + const listener = await ngrok.connect({ + addr: 8080, + authtoken_from_env: true, + proto: "tcp", + proxy_proto: "2", + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#proxy_proto](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#proxy_proto) +- [https://ngrok.github.io/ngrok-nodejs/classes/TcpListenerBuilder.html#proxyProto](https://ngrok.github.io/ngrok-nodejs/classes/TcpListenerBuilder.html#proxyProto) diff --git a/examples/nodejs-sdk/tcp-random.mdx b/examples/nodejs-sdk/tcp-random.mdx new file mode 100644 index 000000000..c55330645 --- /dev/null +++ b/examples/nodejs-sdk/tcp-random.mdx @@ -0,0 +1,19 @@ +```rust +use ngrok::prelude::*; + +(async function () { + const listener = await ngrok.connect({ + addr: 8080, + authtoken_from_env: true, + proto: "tcp", + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs + +- [https://ngrok.github.io/ngrok-nodejs/classes/TcpListenerBuilder.html](https://ngrok.github.io/ngrok-nodejs/classes/TcpListenerBuilder.html) +- [https://ngrok.github.io/ngrok-nodejs/classes/Session.html#tcpEndpoint](https://ngrok.github.io/ngrok-nodejs/classes/Session.html#tcpEndpoint) +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#proto](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#proto) diff --git a/examples/nodejs-sdk/tls-ip-restrictions.mdx b/examples/nodejs-sdk/tls-ip-restrictions.mdx new file mode 100644 index 000000000..db2170c77 --- /dev/null +++ b/examples/nodejs-sdk/tls-ip-restrictions.mdx @@ -0,0 +1,22 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); + +(async function () { + const listener = await ngrok.connect({ + addr: 8080, + authtoken_from_env: true, + proto: "tls", + ip_restriction_allow_cidrs: ["110.0.0.0/8", "220.12.0.0/16"], + ip_restriction_deny_cidrs: "110.2.3.4/32", + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#ip_restriction_allow_cidrs](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#ip_restriction_allow_cidrs) +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#ip_restriction_deny_cidrs](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#ip_restriction_deny_cidrs) +- [https://ngrok.github.io/ngrok-nodejs/classes/TlsListenerBuilder.html#allowCidr](https://ngrok.github.io/ngrok-nodejs/classes/TlsListenerBuilder.html#allowCidr) +- [https://ngrok.github.io/ngrok-nodejs/classes/TlsListenerBuilder.html#denyCidr](https://ngrok.github.io/ngrok-nodejs/classes/TlsListenerBuilder.html#denyCidr) diff --git a/examples/nodejs-sdk/tls-mtls-at-agent.mdx b/examples/nodejs-sdk/tls-mtls-at-agent.mdx new file mode 100644 index 000000000..254dbb911 --- /dev/null +++ b/examples/nodejs-sdk/tls-mtls-at-agent.mdx @@ -0,0 +1,5 @@ +:::info + +The NodeJS SDK does not support Zero-Knowledge Mutual TLS enforcement at the SDK. + +::: diff --git a/examples/nodejs-sdk/tls-mtls-at-edge.mdx b/examples/nodejs-sdk/tls-mtls-at-edge.mdx new file mode 100644 index 000000000..2b3cd5ff9 --- /dev/null +++ b/examples/nodejs-sdk/tls-mtls-at-edge.mdx @@ -0,0 +1,27 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); +const fs = require("fs"); + +(async function () { + const listener = await ngrok.connect({ + addr: 8080, + authtoken_from_env: true, + proto: "tls", + domain: "app.example.com", + crt: fs.readFileSync("/path/to/app-example-com-crt.pem", "utf8"), + key: fs.readFileSync("/path/to/app-example-com-key.pem", "utf8"), + mutual_tls_cas: [fs.readFileSync("/path/to/cas.pem", "utf8")], + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#crt](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#crt) +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#key](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#key) +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#mutual_tls_cas](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#mutual_tls_cas) + +- [https://ngrok.github.io/ngrok-nodejs/classes/TlsListenerBuilder.html#termination](https://ngrok.github.io/ngrok-nodejs/classes/TlsListenerBuilder.html#termination) +- [https://ngrok.github.io/ngrok-nodejs/classes/TlsListenerBuilder.html#mutualTlsca](https://ngrok.github.io/ngrok-nodejs/classes/TlsListenerBuilder.html#mutualTlsca) diff --git a/examples/nodejs-sdk/tls-proxyproto.mdx b/examples/nodejs-sdk/tls-proxyproto.mdx new file mode 100644 index 000000000..1f9d2960d --- /dev/null +++ b/examples/nodejs-sdk/tls-proxyproto.mdx @@ -0,0 +1,19 @@ +```rust +use ngrok::prelude::*; + +(async function () { + const listener = await ngrok.connect({ + addr: 8080, + authtoken_from_env: true, + proto: "tls", + proxy_proto: "2", + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#proxy_proto](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#proxy_proto) +- [https://ngrok.github.io/ngrok-nodejs/classes/TlsListenerBuilder.html#proxyProto](https://ngrok.github.io/ngrok-nodejs/classes/TlsListenerBuilder.html#proxyProto) diff --git a/examples/nodejs-sdk/tls-reencrypt-upstream.mdx b/examples/nodejs-sdk/tls-reencrypt-upstream.mdx new file mode 100644 index 000000000..675b454b5 --- /dev/null +++ b/examples/nodejs-sdk/tls-reencrypt-upstream.mdx @@ -0,0 +1,23 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); + +(async function () { + const listener = await ngrok.connect({ + addr: "tls://localhost:443", + authtoken_from_env: true, + proto: "tls", + crt: "", + key: "", + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +An empty certificate and key will default to the ngrok edge's automatically provisioned keypair. The upstream certificate of `localhost:443` will be validated by a filepath specified in the `SSL_CERT_FILE` environment variable (e.g. `SSL_CERT_FILE=/path/to/ca.crt`), or falling back to the host OS installed trusted certificate authorities. + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/classes/TlsListenerBuilder.html](https://ngrok.github.io/ngrok-nodejs/classes/TlsListenerBuilder.html) +- [https://ngrok.github.io/ngrok-nodejs/classes/Session.html#tlsEndpoint](https://ngrok.github.io/ngrok-nodejs/classes/Session.html#tlsEndpoint) +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#addr](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#addr) diff --git a/examples/nodejs-sdk/tls-terminate-at-agent.mdx b/examples/nodejs-sdk/tls-terminate-at-agent.mdx new file mode 100644 index 000000000..d7c871d4a --- /dev/null +++ b/examples/nodejs-sdk/tls-terminate-at-agent.mdx @@ -0,0 +1,5 @@ +:::info + +The NodeJS SDK does not support TLS termination at the SDK. + +::: diff --git a/examples/nodejs-sdk/tls-terminate-at-edge-custom-cert.mdx b/examples/nodejs-sdk/tls-terminate-at-edge-custom-cert.mdx new file mode 100644 index 000000000..d9a247dcf --- /dev/null +++ b/examples/nodejs-sdk/tls-terminate-at-edge-custom-cert.mdx @@ -0,0 +1,22 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); +const fs = require("fs"); + +(async function () { + const listener = await ngrok.connect({ + addr: 8080, + authtoken_from_env: true, + proto: "tls", + crt: fs.readFileSync("/path/to/app-example-com-crt.pem", "utf8"), + key: fs.readFileSync("/path/to/app-example-com-key.pem", "utf8"), + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#crt](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#crt) +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#key](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#key) +- [https://ngrok.github.io/ngrok-nodejs/classes/TlsListenerBuilder.html#termination](https://ngrok.github.io/ngrok-nodejs/classes/TlsListenerBuilder.html#termination) diff --git a/examples/nodejs-sdk/tls-terminate-at-edge-custom-domain.mdx b/examples/nodejs-sdk/tls-terminate-at-edge-custom-domain.mdx new file mode 100644 index 000000000..2de67e372 --- /dev/null +++ b/examples/nodejs-sdk/tls-terminate-at-edge-custom-domain.mdx @@ -0,0 +1,26 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); +const fs = require("fs"); + +(async function () { + const listener = await ngrok.connect({ + addr: 8080, + authtoken_from_env: true, + proto: "tls", + domain: "app.example.com", + crt: fs.readFileSync("/path/to/app-example-com-crt.pem", "utf8"), + key: fs.readFileSync("/path/to/app-example-com-key.pem", "utf8"), + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#domain](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#domain) +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#crt](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#crt) +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#key](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#key) + +- [https://ngrok.github.io/ngrok-nodejs/classes/TlsListenerBuilder.html#domain](https://ngrok.github.io/ngrok-nodejs/classes/TlsListenerBuilder.html#domain) +- [https://ngrok.github.io/ngrok-nodejs/classes/TlsListenerBuilder.html#termination](https://ngrok.github.io/ngrok-nodejs/classes/TlsListenerBuilder.html#termination) diff --git a/examples/nodejs-sdk/tls-terminate-at-edge.mdx b/examples/nodejs-sdk/tls-terminate-at-edge.mdx new file mode 100644 index 000000000..5fbd18abf --- /dev/null +++ b/examples/nodejs-sdk/tls-terminate-at-edge.mdx @@ -0,0 +1,23 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); + +(async function () { + const listener = await ngrok.connect({ + addr: 8080, + authtoken_from_env: true, + proto: "tls", + crt: "", + key: "", + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +An empty certificate and key will default to the ngrok edge's automatically provisioned keypair. + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/classes/TlsListenerBuilder.html](https://ngrok.github.io/ngrok-nodejs/classes/TlsListenerBuilder.html) +- [https://ngrok.github.io/ngrok-nodejs/classes/Session.html#tlsEndpoint](https://ngrok.github.io/ngrok-nodejs/classes/Session.html#tlsEndpoint) +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#proto](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#proto) diff --git a/examples/nodejs-sdk/tls-terminate-at-upstream.mdx b/examples/nodejs-sdk/tls-terminate-at-upstream.mdx new file mode 100644 index 000000000..afebfae7b --- /dev/null +++ b/examples/nodejs-sdk/tls-terminate-at-upstream.mdx @@ -0,0 +1,19 @@ +```jsx +const ngrok = require("@ngrok/ngrok"); + +(async function () { + const listener = await ngrok.connect({ + addr: 8080, + authtoken_from_env: true, + proto: "tls", + domain: "app.example.com", + }); + + console.log(`Ingress established at: ${listener.url()}`); +})(); +``` + +NodeJS SDK Docs: + +- [https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#domain](https://ngrok.github.io/ngrok-nodejs/interfaces/Config.html#domain) +- [https://ngrok.github.io/ngrok-nodejs/classes/TlsListenerBuilder.html#domain](https://ngrok.github.io/ngrok-nodejs/classes/TlsListenerBuilder.html#domain) diff --git a/examples/python-sdk/custom-agent-ingress.mdx b/examples/python-sdk/custom-agent-ingress.mdx new file mode 100644 index 000000000..a9735d0e9 --- /dev/null +++ b/examples/python-sdk/custom-agent-ingress.mdx @@ -0,0 +1,22 @@ +```python +import ngrok, asyncio + +async def create_listener() -> ngrok.Listener: + session: ngrok.Session = ( + await ngrok.SessionBuilder() + .authtoken_from_env() + .server_addr("us.agents.example.com:443") + .connect() + ) + + return (await session.http_endpoint() + .listen_and_forward("http://localhost:8080")) + +listener = asyncio.run(create_listener()) + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/session_builder.html#ngrok.SessionBuilder.server_addr](https://ngrok.github.io/ngrok-python/session_builder.html#ngrok.SessionBuilder.server_addr) diff --git a/examples/python-sdk/explicit-region.mdx b/examples/python-sdk/explicit-region.mdx new file mode 100644 index 000000000..497af11a0 --- /dev/null +++ b/examples/python-sdk/explicit-region.mdx @@ -0,0 +1,22 @@ +```python +import ngrok, asyncio + +async def create_listener() -> ngrok.Listener: + session: ngrok.Session = ( + await ngrok.SessionBuilder() + .authtoken_from_env() + .server_addr("connect.eu.ngrok-agent.com:443") + .connect() + ) + + return (await session.http_endpoint() + .listen_and_forward("http://localhost:8080")) + +listener = asyncio.run(create_listener()) + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/session_builder.html#ngrok.SessionBuilder.server_addr](https://ngrok.github.io/ngrok-python/session_builder.html#ngrok.SessionBuilder.server_addr) diff --git a/examples/python-sdk/http-basic-auth.mdx b/examples/python-sdk/http-basic-auth.mdx new file mode 100644 index 000000000..ea41948b2 --- /dev/null +++ b/examples/python-sdk/http-basic-auth.mdx @@ -0,0 +1,13 @@ +```python +import ngrok + +listener = ngrok.connect("localhost:8080", authtoken_from_env=True, + basic_auth=["username1:password1", "username2:password2"]) + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.basic_auth](https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.basic_auth) +- [https://ngrok.github.io/ngrok-python/index.html#full-configuration](https://ngrok.github.io/ngrok-python/index.html#full-configuration) diff --git a/examples/python-sdk/http-branded-domain.mdx b/examples/python-sdk/http-branded-domain.mdx new file mode 100644 index 000000000..00e5bdfda --- /dev/null +++ b/examples/python-sdk/http-branded-domain.mdx @@ -0,0 +1,13 @@ +```python +import ngrok + +listener = ngrok.connect("localhost:8080", authtoken_from_env=True, + domain="example.ngrok.app") + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.domain](https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.domain) +- [https://ngrok.github.io/ngrok-python/index.html#full-configuration](https://ngrok.github.io/ngrok-python/index.html#full-configuration) diff --git a/examples/python-sdk/http-circuit-breaker.mdx b/examples/python-sdk/http-circuit-breaker.mdx new file mode 100644 index 000000000..80a708a5a --- /dev/null +++ b/examples/python-sdk/http-circuit-breaker.mdx @@ -0,0 +1,13 @@ +```python +import ngrok + +listener = ngrok.connect("localhost:8080", authtoken_from_env=True, + circuit_breaker=0.5) + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.circuit_breaker](https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.circuit_breaker) +- [https://ngrok.github.io/ngrok-python/index.html#full-configuration](https://ngrok.github.io/ngrok-python/index.html#full-configuration) diff --git a/examples/python-sdk/http-compression.mdx b/examples/python-sdk/http-compression.mdx new file mode 100644 index 000000000..aae90d929 --- /dev/null +++ b/examples/python-sdk/http-compression.mdx @@ -0,0 +1,13 @@ +```python +import ngrok + +listener = ngrok.connect("localhost:8080", authtoken_from_env=True, + compression=True) + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.compression](https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.compression) +- [https://ngrok.github.io/ngrok-python/index.html#full-configuration](https://ngrok.github.io/ngrok-python/index.html#full-configuration) diff --git a/examples/python-sdk/http-fileserver-abs-path.mdx b/examples/python-sdk/http-fileserver-abs-path.mdx new file mode 100644 index 000000000..de2d329f1 --- /dev/null +++ b/examples/python-sdk/http-fileserver-abs-path.mdx @@ -0,0 +1,5 @@ +:::info + +Serving directory files is not supported in the Python SDK. + +::: diff --git a/examples/python-sdk/http-fileserver-windows.mdx b/examples/python-sdk/http-fileserver-windows.mdx new file mode 100644 index 000000000..de2d329f1 --- /dev/null +++ b/examples/python-sdk/http-fileserver-windows.mdx @@ -0,0 +1,5 @@ +:::info + +Serving directory files is not supported in the Python SDK. + +::: diff --git a/examples/python-sdk/http-fileserver-working-dir.mdx b/examples/python-sdk/http-fileserver-working-dir.mdx new file mode 100644 index 000000000..de2d329f1 --- /dev/null +++ b/examples/python-sdk/http-fileserver-working-dir.mdx @@ -0,0 +1,5 @@ +:::info + +Serving directory files is not supported in the Python SDK. + +::: diff --git a/examples/python-sdk/http-forward-https.mdx b/examples/python-sdk/http-forward-https.mdx new file mode 100644 index 000000000..d983c237a --- /dev/null +++ b/examples/python-sdk/http-forward-https.mdx @@ -0,0 +1,12 @@ +```python +import ngrok + +listener = ngrok.connect("https://localhost:8443", authtoken_from_env=True) + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/module.html#ngrok.connect](https://ngrok.github.io/ngrok-python/module.html#ngrok.connect) +- [https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.listen_and_forward](https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.listen_and_forward) diff --git a/examples/python-sdk/http-ip-restrictions.mdx b/examples/python-sdk/http-ip-restrictions.mdx new file mode 100644 index 000000000..a49f0be51 --- /dev/null +++ b/examples/python-sdk/http-ip-restrictions.mdx @@ -0,0 +1,15 @@ +```python +import ngrok + +listener = ngrok.connect("localhost:8080", authtoken_from_env=True, + ip_restriction_allow_cidrs=["110.0.0.0/8", "220.12.0.0/16"], + ip_restriction_deny_cidrs="110.2.3.4/32") + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.allow_cidr](https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.allow_cidr) +- [https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.deny_cidr](https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.deny_cidr) +- [https://ngrok.github.io/ngrok-python/index.html#full-configuration](https://ngrok.github.io/ngrok-python/index.html#full-configuration) diff --git a/examples/python-sdk/http-mutual-tls.mdx b/examples/python-sdk/http-mutual-tls.mdx new file mode 100644 index 000000000..7169189ba --- /dev/null +++ b/examples/python-sdk/http-mutual-tls.mdx @@ -0,0 +1,17 @@ +```python +import ngrok + +def load_file(name): + with open(name, "r") as crt: + return bytearray(crt.read().encode()) + +listener = ngrok.connect("localhost:8080", authtoken_from_env=True, + mutual_tls_cas=load_file("/path/to/cas.pem")) + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.mutual_tlsca](https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.mutual_tlsca) +- [https://ngrok.github.io/ngrok-python/index.html#full-configuration](https://ngrok.github.io/ngrok-python/index.html#full-configuration) diff --git a/examples/python-sdk/http-nonlocal.mdx b/examples/python-sdk/http-nonlocal.mdx new file mode 100644 index 000000000..32bd32ce1 --- /dev/null +++ b/examples/python-sdk/http-nonlocal.mdx @@ -0,0 +1,12 @@ +```python +import ngrok + +listener = ngrok.connect("192.168.1.2:80", authtoken_from_env=True) + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/module.html#ngrok.connect](https://ngrok.github.io/ngrok-python/module.html#ngrok.connect) +- [https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.listen_and_forward](https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.listen_and_forward) diff --git a/examples/python-sdk/http-oauth-authn.mdx b/examples/python-sdk/http-oauth-authn.mdx new file mode 100644 index 000000000..611e091a7 --- /dev/null +++ b/examples/python-sdk/http-oauth-authn.mdx @@ -0,0 +1,13 @@ +```python +import ngrok + +listener = ngrok.connect("localhost:8080", authtoken_from_env=True, + oauth_provider="google") + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.oauth](https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.oauth) +- [https://ngrok.github.io/ngrok-python/index.html#full-configuration](https://ngrok.github.io/ngrok-python/index.html#full-configuration) diff --git a/examples/python-sdk/http-oauth-authz.mdx b/examples/python-sdk/http-oauth-authz.mdx new file mode 100644 index 000000000..32b6e7c0f --- /dev/null +++ b/examples/python-sdk/http-oauth-authz.mdx @@ -0,0 +1,15 @@ +```python +import ngrok + +listener = ngrok.connect("localhost:8080", authtoken_from_env=True, + oauth_provider="google", + oauth_allow_emails="kate.libby@gmail.com", + oauth_allow_domains="acme.org") + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.oauth](https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.oauth) +- [https://ngrok.github.io/ngrok-python/index.html#full-configuration](https://ngrok.github.io/ngrok-python/index.html#full-configuration) diff --git a/examples/python-sdk/http-oauth-byo-app.mdx b/examples/python-sdk/http-oauth-byo-app.mdx new file mode 100644 index 000000000..6d749a9c8 --- /dev/null +++ b/examples/python-sdk/http-oauth-byo-app.mdx @@ -0,0 +1,15 @@ +```python +import ngrok + +listener = ngrok.connect("localhost:8080", authtoken_from_env=True, + oauth_provider="microsoft", + oauth_client_id="{client id}", + oauth_client_secret="{client secret}") + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.oauth](https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.oauth) +- [https://ngrok.github.io/ngrok-python/index.html#full-configuration](https://ngrok.github.io/ngrok-python/index.html#full-configuration) diff --git a/examples/python-sdk/http-oauth-customize-scopes.mdx b/examples/python-sdk/http-oauth-customize-scopes.mdx new file mode 100644 index 000000000..8ee2cc837 --- /dev/null +++ b/examples/python-sdk/http-oauth-customize-scopes.mdx @@ -0,0 +1,16 @@ +```python +import ngrok + +listener = ngrok.connect("localhost:8080", authtoken_from_env=True, + oauth_provider="github", + oauth_client_id="{client id}", + oauth_client_secret="{client secret}", + oauth_scopes=["repo", "user"]) + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.oauth](https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.oauth) +- [https://ngrok.github.io/ngrok-python/index.html#full-configuration](https://ngrok.github.io/ngrok-python/index.html#full-configuration) diff --git a/examples/python-sdk/http-random.mdx b/examples/python-sdk/http-random.mdx new file mode 100644 index 000000000..11e871254 --- /dev/null +++ b/examples/python-sdk/http-random.mdx @@ -0,0 +1,13 @@ +```python +import ngrok + +listener = ngrok.connect("localhost:8080", authtoken_from_env=True) + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/http_listener_builder.html](https://ngrok.github.io/ngrok-python/http_listener_builder.html) +- [https://ngrok.github.io/ngrok-python/session.html#ngrok.Session.http_endpoint](https://ngrok.github.io/ngrok-python/session.html#ngrok.Session.http_endpoint) +- [https://ngrok.github.io/ngrok-python/module.html#ngrok.connect](https://ngrok.github.io/ngrok-python/module.html#ngrok.connect) diff --git a/examples/python-sdk/http-request-headers.mdx b/examples/python-sdk/http-request-headers.mdx new file mode 100644 index 000000000..5e1ec439f --- /dev/null +++ b/examples/python-sdk/http-request-headers.mdx @@ -0,0 +1,15 @@ +```python +import ngrok + +listener = ngrok.connect("localhost:8080", authtoken_from_env=True, + request_header_add=["is-ngrok:1", "country:${.ngrok.geo.country_code}"], + request_header_remove="referrer") + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.request_header](https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.request_header) +- [https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.remove_request_header] (https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.remove_request_header) +- [https://ngrok.github.io/ngrok-python/index.html#full-configuration](https://ngrok.github.io/ngrok-python/index.html#full-configuration) diff --git a/examples/python-sdk/http-response-headers.mdx b/examples/python-sdk/http-response-headers.mdx new file mode 100644 index 000000000..3a4d7ee23 --- /dev/null +++ b/examples/python-sdk/http-response-headers.mdx @@ -0,0 +1,15 @@ +```python +import ngrok + +listener = ngrok.connect("localhost:8080", authtoken_from_env=True, + response_header_add=["content-security-policy:self", "dial-duration:${.backend.dial_duration}"], + response_header_remove="internal-trace-id") + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.response_header](https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.response_header) +- [https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.remove_response_header](https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.remove_response_header) +- [https://ngrok.github.io/ngrok-python/index.html#full-configuration](https://ngrok.github.io/ngrok-python/index.html#full-configuration) diff --git a/examples/python-sdk/http-rewrite-host-header.mdx b/examples/python-sdk/http-rewrite-host-header.mdx new file mode 100644 index 000000000..1a89d5933 --- /dev/null +++ b/examples/python-sdk/http-rewrite-host-header.mdx @@ -0,0 +1,13 @@ +```python +import ngrok + +listener = ngrok.connect("localhost:8080", authtoken_from_env=True, + request_header_add="host:localhost") + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.request_header](https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.request_header) +- [https://ngrok.github.io/ngrok-python/index.html#full-configuration](https://ngrok.github.io/ngrok-python/index.html#full-configuration) diff --git a/examples/python-sdk/http-schemes.mdx b/examples/python-sdk/http-schemes.mdx new file mode 100644 index 000000000..a7be0391e --- /dev/null +++ b/examples/python-sdk/http-schemes.mdx @@ -0,0 +1,13 @@ +```python +import ngrok + +listener = ngrok.connect("localhost:8080", authtoken_from_env=True, + schemes="http") + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.scheme](https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.scheme) +- [https://ngrok.github.io/ngrok-python/index.html#full-configuration](https://ngrok.github.io/ngrok-python/index.html#full-configuration) diff --git a/examples/python-sdk/http-static-domain.mdx b/examples/python-sdk/http-static-domain.mdx new file mode 100644 index 000000000..00e5bdfda --- /dev/null +++ b/examples/python-sdk/http-static-domain.mdx @@ -0,0 +1,13 @@ +```python +import ngrok + +listener = ngrok.connect("localhost:8080", authtoken_from_env=True, + domain="example.ngrok.app") + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.domain](https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.domain) +- [https://ngrok.github.io/ngrok-python/index.html#full-configuration](https://ngrok.github.io/ngrok-python/index.html#full-configuration) diff --git a/examples/python-sdk/http-tls-termination.mdx b/examples/python-sdk/http-tls-termination.mdx new file mode 100644 index 000000000..a7942587a --- /dev/null +++ b/examples/python-sdk/http-tls-termination.mdx @@ -0,0 +1,5 @@ +:::info + +TLS termination is not configurable via the Python SDK + +::: diff --git a/examples/python-sdk/http-user-agent-filter.mdx b/examples/python-sdk/http-user-agent-filter.mdx new file mode 100644 index 000000000..55fe99457 --- /dev/null +++ b/examples/python-sdk/http-user-agent-filter.mdx @@ -0,0 +1,15 @@ +```python +import ngrok + +listener = ngrok.connect("localhost:8080", authtoken_from_env=True, + allow_user_agent="foo/(\d)+", + deny_user_agent="bar/(\d)+") + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.allow_user_agent](https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.allow_user_agent) +- [https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.deny_user_agent](https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.deny_user_agent) +- [https://ngrok.github.io/ngrok-python/index.html#full-configuration](https://ngrok.github.io/ngrok-python/index.html#full-configuration) diff --git a/examples/python-sdk/http-webhook-verification.mdx b/examples/python-sdk/http-webhook-verification.mdx new file mode 100644 index 000000000..f62d792f5 --- /dev/null +++ b/examples/python-sdk/http-webhook-verification.mdx @@ -0,0 +1,14 @@ +```python +import ngrok + +listener = ngrok.connect("localhost:8080", authtoken_from_env=True, + verify_webhook_provider="twilio", + verify_webhook_secret="{twilio signing secret}") + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.webhook_verification](https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.webhook_verification) +- [https://ngrok.github.io/ngrok-python/index.html#full-configuration](https://ngrok.github.io/ngrok-python/index.html#full-configuration) diff --git a/examples/python-sdk/http-websocket-tcp-converter.mdx b/examples/python-sdk/http-websocket-tcp-converter.mdx new file mode 100644 index 000000000..89b26ddca --- /dev/null +++ b/examples/python-sdk/http-websocket-tcp-converter.mdx @@ -0,0 +1,13 @@ +```python +import ngrok + +listener = ngrok.connect("localhost:8080", authtoken_from_env=True, + websocket_tcp_converter=True) + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.websocket_tcp_conversion](https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.websocket_tcp_conversion) +- [https://ngrok.github.io/ngrok-python/index.html#full-configuration](https://ngrok.github.io/ngrok-python/index.html#full-configuration) diff --git a/examples/python-sdk/http-wildcard-domain.mdx b/examples/python-sdk/http-wildcard-domain.mdx new file mode 100644 index 000000000..275f37333 --- /dev/null +++ b/examples/python-sdk/http-wildcard-domain.mdx @@ -0,0 +1,13 @@ +```python +import ngrok + +listener = ngrok.connect("localhost:8080", authtoken_from_env=True, + domain="*.example.com") + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.domain](https://ngrok.github.io/ngrok-python/http_listener_builder.html#ngrok.HttpListenerBuilder.domain) +- [https://ngrok.github.io/ngrok-python/index.html#full-configuration](https://ngrok.github.io/ngrok-python/index.html#full-configuration) diff --git a/examples/python-sdk/tcp-fixed.mdx b/examples/python-sdk/tcp-fixed.mdx new file mode 100644 index 000000000..1d290fe0f --- /dev/null +++ b/examples/python-sdk/tcp-fixed.mdx @@ -0,0 +1,14 @@ +```python +import ngrok + +listener = ngrok.connect("localhost:8080", authtoken_from_env=True, + proto="tcp", + remote_addr="1.tcp.eu.ngrok.io:12345") + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/tcp_listener_builder.html#ngrok.TcpListenerBuilder.remote_addr](https://ngrok.github.io/ngrok-python/tcp_listener_builder.html#ngrok.TcpListenerBuilder.remote_addr) +- [https://ngrok.github.io/ngrok-python/index.html#full-configuration](https://ngrok.github.io/ngrok-python/index.html#full-configuration) diff --git a/examples/python-sdk/tcp-ip-restrictions.mdx b/examples/python-sdk/tcp-ip-restrictions.mdx new file mode 100644 index 000000000..0022f8909 --- /dev/null +++ b/examples/python-sdk/tcp-ip-restrictions.mdx @@ -0,0 +1,16 @@ +```python +import ngrok + +listener = ngrok.connect("localhost:8080", authtoken_from_env=True, + proto="tcp", + ip_restriction_allow_cidrs=["110.0.0.0/8", "220.12.0.0/16"], + ip_restriction_deny_cidrs="110.2.3.4/32") + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/tcp_listener_builder.html#ngrok.TcpListenerBuilder.allow_cidr](https://ngrok.github.io/ngrok-python/tcp_listener_builder.html#ngrok.TcpListenerBuilder.allow_cidr) +- [https://ngrok.github.io/ngrok-python/tcp_listener_builder.html#ngrok.TcpListenerBuilder.deny_cidr](https://ngrok.github.io/ngrok-python/tcp_listener_builder.html#ngrok.TcpListenerBuilder.deny_cidr) +- [https://ngrok.github.io/ngrok-python/index.html#full-configuration](https://ngrok.github.io/ngrok-python/index.html#full-configuration) diff --git a/examples/python-sdk/tcp-nonlocal.mdx b/examples/python-sdk/tcp-nonlocal.mdx new file mode 100644 index 000000000..d6229eb87 --- /dev/null +++ b/examples/python-sdk/tcp-nonlocal.mdx @@ -0,0 +1,13 @@ +```python +import ngrok + +listener = ngrok.connect("192.168.1.2:5432", authtoken_from_env=True, + proto="tcp") + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/module.html#ngrok.connect](https://ngrok.github.io/ngrok-python/module.html#ngrok.connect) +- [https://ngrok.github.io/ngrok-python/tcp_listener_builder.html#ngrok.TcpListenerBuilder.listen_and_forward](https://ngrok.github.io/ngrok-python/tcp_listener_builder.html#ngrok.TcpListenerBuilder.listen_and_forward) diff --git a/examples/python-sdk/tcp-proxyproto.mdx b/examples/python-sdk/tcp-proxyproto.mdx new file mode 100644 index 000000000..ebfac0410 --- /dev/null +++ b/examples/python-sdk/tcp-proxyproto.mdx @@ -0,0 +1,14 @@ +```python +import ngrok + +listener = ngrok.connect("localhost:8080", authtoken_from_env=True, + proto="tcp", + proxy_proto="2") + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/tcp_listener_builder.html#ngrok.TcpListenerBuilder.proxy_proto](https://ngrok.github.io/ngrok-python/tcp_listener_builder.html#ngrok.TcpListenerBuilder.proxy_proto) +- [https://ngrok.github.io/ngrok-python/index.html#full-configuration](https://ngrok.github.io/ngrok-python/index.html#full-configuration) diff --git a/examples/python-sdk/tcp-random.mdx b/examples/python-sdk/tcp-random.mdx new file mode 100644 index 000000000..70be9d3af --- /dev/null +++ b/examples/python-sdk/tcp-random.mdx @@ -0,0 +1,13 @@ +```python +import ngrok + +listener = ngrok.connect("localhost:8080", authtoken_from_env=True, + proto="tcp") + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/module.html#ngrok.connect](https://ngrok.github.io/ngrok-python/module.html#ngrok.connect) +- [https://ngrok.github.io/ngrok-python/tcp_listener_builder.html#ngrok.TcpListenerBuilder.listen_and_forward](https://ngrok.github.io/ngrok-python/tcp_listener_builder.html#ngrok.TcpListenerBuilder.listen_and_forward) diff --git a/examples/python-sdk/tls-ip-restrictions.mdx b/examples/python-sdk/tls-ip-restrictions.mdx new file mode 100644 index 000000000..0c629a0e1 --- /dev/null +++ b/examples/python-sdk/tls-ip-restrictions.mdx @@ -0,0 +1,16 @@ +```python +import ngrok + +listener = ngrok.connect("localhost:8080", authtoken_from_env=True, + proto="tls", + ip_restriction_allow_cidrs=["110.0.0.0/8", "220.12.0.0/16"], + ip_restriction_deny_cidrs="110.2.3.4/32") + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/tls_listener_builder.html#ngrok.TlsListenerBuilder.allow_cidr](https://ngrok.github.io/ngrok-python/tls_listener_builder.html#ngrok.TlsListenerBuilder.allow_cidr) +- [https://ngrok.github.io/ngrok-python/tls_listener_builder.html#ngrok.TlsListenerBuilder.deny_cidr](https://ngrok.github.io/ngrok-python/tls_listener_builder.html#ngrok.TlsListenerBuilder.deny_cidr) +- [https://ngrok.github.io/ngrok-python/index.html#full-configuration](https://ngrok.github.io/ngrok-python/index.html#full-configuration) diff --git a/examples/python-sdk/tls-mtls-at-agent.mdx b/examples/python-sdk/tls-mtls-at-agent.mdx new file mode 100644 index 000000000..5831ebcb8 --- /dev/null +++ b/examples/python-sdk/tls-mtls-at-agent.mdx @@ -0,0 +1,5 @@ +:::info + +The Python SDK does not support Zero-Knowledge Mutual TLS enforcement at the SDK. + +::: diff --git a/examples/python-sdk/tls-mtls-at-edge.mdx b/examples/python-sdk/tls-mtls-at-edge.mdx new file mode 100644 index 000000000..cddf5e015 --- /dev/null +++ b/examples/python-sdk/tls-mtls-at-edge.mdx @@ -0,0 +1,22 @@ +```python +import ngrok + +def load_file(name): + with open(name, "r") as crt: + return bytearray(crt.read().encode()) + +listener = ngrok.connect("localhost:8080", authtoken_from_env=True, + proto="tls", + domain="app.example.com", + crt=load_file("/path/to/app-example-com-crt.pem"), + key=load_file("/path/to/app-example-com-key.pem"), + mutual_tls_cas=load_file("/path/to/cas.pem")) + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/tls_listener_builder.html#ngrok.TlsListenerBuilder.mutual_tlsca](https://ngrok.github.io/ngrok-python/tls_listener_builder.html#ngrok.TlsListenerBuilder.mutual_tlsca) +- [https://ngrok.github.io/ngrok-python/tls_listener_builder.html#ngrok.TlsListenerBuilder.termination](https://ngrok.github.io/ngrok-python/tls_listener_builder.html#ngrok.TlsListenerBuilder.termination) +- [https://ngrok.github.io/ngrok-python/index.html#full-configuration](https://ngrok.github.io/ngrok-python/index.html#full-configuration) diff --git a/examples/python-sdk/tls-proxyproto.mdx b/examples/python-sdk/tls-proxyproto.mdx new file mode 100644 index 000000000..f90f1e39a --- /dev/null +++ b/examples/python-sdk/tls-proxyproto.mdx @@ -0,0 +1,14 @@ +```python +import ngrok + +listener = ngrok.connect("localhost:8080", authtoken_from_env=True, + proto="tls", + proxy_proto="2") + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/tls_listener_builder.html#ngrok.TlsListenerBuilder.proxy_proto](https://ngrok.github.io/ngrok-python/tls_listener_builder.html#ngrok.TlsListenerBuilder.proxy_proto) +- [https://ngrok.github.io/ngrok-python/index.html#full-configuration](https://ngrok.github.io/ngrok-python/index.html#full-configuration) diff --git a/examples/python-sdk/tls-reencrypt-upstream.mdx b/examples/python-sdk/tls-reencrypt-upstream.mdx new file mode 100644 index 000000000..1d7983735 --- /dev/null +++ b/examples/python-sdk/tls-reencrypt-upstream.mdx @@ -0,0 +1,17 @@ +```python +import ngrok + +listener = ngrok.connect("tls://localhost:443", authtoken_from_env=True, + proto="tls" + crt=bytearray(), + key=bytearray()) + +print(f"Ingress established at: {listener.url()}"); +``` + +An empty certificate and key will default to the ngrok edge's automatically provisioned keypair. The upstream certificate of `localhost:443` will be validated by a filepath specified in the `SSL_CERT_FILE` environment variable (e.g. `SSL_CERT_FILE=/path/to/ca.crt`), or falling back to the host OS installed trusted certificate authorities. + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/module.html#ngrok.connect](https://ngrok.github.io/ngrok-python/module.html#ngrok.connect) +- [https://ngrok.github.io/ngrok-python/index.html#full-configuration](https://ngrok.github.io/ngrok-python/index.html#full-configuration) diff --git a/examples/python-sdk/tls-terminate-at-agent.mdx b/examples/python-sdk/tls-terminate-at-agent.mdx new file mode 100644 index 000000000..4244a644f --- /dev/null +++ b/examples/python-sdk/tls-terminate-at-agent.mdx @@ -0,0 +1,5 @@ +:::info + +The Python SDK does not support TLS termination at the SDK. + +::: diff --git a/examples/python-sdk/tls-terminate-at-edge-custom-cert.mdx b/examples/python-sdk/tls-terminate-at-edge-custom-cert.mdx new file mode 100644 index 000000000..2c312b267 --- /dev/null +++ b/examples/python-sdk/tls-terminate-at-edge-custom-cert.mdx @@ -0,0 +1,19 @@ +```python +import ngrok + +def load_file(name): + with open(name, "r") as crt: + return bytearray(crt.read().encode()) + +listener = ngrok.connect("localhost:8080", authtoken_from_env=True, + proto="tls", + crt=load_file("/path/to/app-example-com-crt.pem"), + key=load_file("/path/to/app-example-com-key.pem")) + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/tls_listener_builder.html#ngrok.TlsListenerBuilder.termination](https://ngrok.github.io/ngrok-python/tls_listener_builder.html#ngrok.TlsListenerBuilder.termination) +- [https://ngrok.github.io/ngrok-python/index.html#full-configuration](https://ngrok.github.io/ngrok-python/index.html#full-configuration) diff --git a/examples/python-sdk/tls-terminate-at-edge-custom-domain.mdx b/examples/python-sdk/tls-terminate-at-edge-custom-domain.mdx new file mode 100644 index 000000000..41e55ff43 --- /dev/null +++ b/examples/python-sdk/tls-terminate-at-edge-custom-domain.mdx @@ -0,0 +1,21 @@ +```python +import ngrok + +def load_file(name): + with open(name, "r") as crt: + return bytearray(crt.read().encode()) + +listener = ngrok.connect("localhost:8080", authtoken_from_env=True, + proto="tls", + domain="app.example.com", + crt=load_file("/path/to/app-example-com-crt.pem"), + key=load_file("/path/to/app-example-com-key.pem")) + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/tls_listener_builder.html#ngrok.TlsListenerBuilder.domain](https://ngrok.github.io/ngrok-python/tls_listener_builder.html#ngrok.TlsListenerBuilder.domain) +- [https://ngrok.github.io/ngrok-python/tls_listener_builder.html#ngrok.TlsListenerBuilder.termination](https://ngrok.github.io/ngrok-python/tls_listener_builder.html#ngrok.TlsListenerBuilder.termination) +- [https://ngrok.github.io/ngrok-python/index.html#full-configuration](https://ngrok.github.io/ngrok-python/index.html#full-configuration) diff --git a/examples/python-sdk/tls-terminate-at-edge.mdx b/examples/python-sdk/tls-terminate-at-edge.mdx new file mode 100644 index 000000000..c7bee6096 --- /dev/null +++ b/examples/python-sdk/tls-terminate-at-edge.mdx @@ -0,0 +1,17 @@ +```python +import ngrok + +listener = ngrok.connect("localhost:8080", authtoken_from_env=True, + proto="tls" + crt=bytearray(), + key=bytearray()) + +print(f"Ingress established at: {listener.url()}"); +``` + +An empty certificate and key will default to the ngrok edge's automatically provisioned keypair. + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/tls_listener_builder.html#ngrok.TlsListenerBuilder.termination](https://ngrok.github.io/ngrok-python/tls_listener_builder.html#ngrok.TlsListenerBuilder.termination) +- [https://ngrok.github.io/ngrok-python/index.html#full-configuration](https://ngrok.github.io/ngrok-python/index.html#full-configuration) diff --git a/examples/python-sdk/tls-terminate-at-upstream.mdx b/examples/python-sdk/tls-terminate-at-upstream.mdx new file mode 100644 index 000000000..b38b54cbd --- /dev/null +++ b/examples/python-sdk/tls-terminate-at-upstream.mdx @@ -0,0 +1,14 @@ +```python +import ngrok + +listener = ngrok.connect("localhost:8080", authtoken_from_env=True, + proto="tls", + domain="app.example.com") + +print(f"Ingress established at: {listener.url()}"); +``` + +Python SDK Docs: + +- [https://ngrok.github.io/ngrok-python/tls_listener_builder.html#ngrok.TlsListenerBuilder.domain](https://ngrok.github.io/ngrok-python/tls_listener_builder.html#ngrok.TlsListenerBuilder.domain) +- [https://ngrok.github.io/ngrok-python/index.html#full-configuration](https://ngrok.github.io/ngrok-python/index.html#full-configuration) diff --git a/examples/rust-sdk/http-schemes.mdx b/examples/rust-sdk/http-schemes.mdx index e5c47e1d2..26647f095 100644 --- a/examples/rust-sdk/http-schemes.mdx +++ b/examples/rust-sdk/http-schemes.mdx @@ -9,7 +9,7 @@ async fn listen_ngrok() -> anyhow::Result { let tun = sess .http_endpoint() - .schemes("http", "https") + .scheme("http") .listen() .await?; @@ -21,4 +21,4 @@ async fn listen_ngrok() -> anyhow::Result { Rust Crate Docs: -- [https://docs.rs/ngrok/latest/ngrok/config/struct.HttpTunnelBuilder.html#method.basic_auth](https://docs.rs/ngrok/latest/ngrok/config/struct.HttpTunnelBuilder.html#method.basic_auth) +- [https://docs.rs/ngrok/latest/ngrok/config/struct.HttpTunnelBuilder.html#method.scheme](https://docs.rs/ngrok/latest/ngrok/config/struct.HttpTunnelBuilder.html#method.scheme) diff --git a/examples/rust-sdk/tcp-fixed.mdx b/examples/rust-sdk/tcp-fixed.mdx index b72fb086f..ee3417360 100644 --- a/examples/rust-sdk/tcp-fixed.mdx +++ b/examples/rust-sdk/tcp-fixed.mdx @@ -4,7 +4,6 @@ use ngrok::prelude::*; async fn listen_ngrok() -> anyhow::Result { let sess = ngrok::Session::builder() .authtoken_from_env() - .server_addr("connect.eu.ngrok-agent.com:443"), .connect() .await?; diff --git a/examples/rust-sdk/tls-reencrypt-upstream.mdx b/examples/rust-sdk/tls-reencrypt-upstream.mdx index 100cab1bc..0f36d0d34 100644 --- a/examples/rust-sdk/tls-reencrypt-upstream.mdx +++ b/examples/rust-sdk/tls-reencrypt-upstream.mdx @@ -1,5 +1,5 @@ :::info -Re-encrypting the connection to your upstream service with TLS is not supported in the Rust SDK. +Re-encrypting the connection to your upstream service with TLS is not yet supported in the Rust SDK. ::: diff --git a/examples/rust-sdk/tls-terminate-at-edge.mdx b/examples/rust-sdk/tls-terminate-at-edge.mdx index 639817c4e..370f410eb 100644 --- a/examples/rust-sdk/tls-terminate-at-edge.mdx +++ b/examples/rust-sdk/tls-terminate-at-edge.mdx @@ -9,6 +9,7 @@ async fn listen_ngrok() -> anyhow::Result { let tun = sess .tls_endpoint() + .termination(Bytes::new(), Bytes::new()) .listen() .await?; @@ -18,6 +19,8 @@ async fn listen_ngrok() -> anyhow::Result { } ``` +An empty certificate and key will default to the ngrok edge's automatically provisioned keypair. + Rust Crate Docs: - [https://docs.rs/ngrok/latest/ngrok/session/struct.Session.html#method.tls_endpoint](https://docs.rs/ngrok/latest/ngrok/session/struct.Session.html#method.tls_endpoint)