From a9470b41c7ef6c084ba79489478aa68a878e58c2 Mon Sep 17 00:00:00 2001 From: Niji Date: Tue, 29 Oct 2024 17:08:20 -0700 Subject: [PATCH] feat: getting-started rough draft --- docs/traffic-policy/getting-started.mdx | 48 +++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/docs/traffic-policy/getting-started.mdx b/docs/traffic-policy/getting-started.mdx index f15cbd374..8439f0d64 100644 --- a/docs/traffic-policy/getting-started.mdx +++ b/docs/traffic-policy/getting-started.mdx @@ -1,3 +1,51 @@ --- title: Getting Started --- + +# Getting Started with Traffic Policy + +## Prerequisites + +1. **ngrok Account** - Ensure you have an active [ngrok](https://dashboard.ngrok.com/) account. +2. **ngrok Agent** - Download and install the [ngrok agent](https://ngrok.com/download) for your operating system. + +## Step 1: Create a Traffic Policy + +Create a custom traffic policy by saving the following YAML configuration as `policy.yml`: + +``` +on_http_request: + - actions: + - type: custom-response + config: + content: "Hello, World!" +``` + +This policy will respond to each HTTP request with a simple “Hello, World!” message. + +## Step 2: Apply Your Traffic Policy + +Run the agent, applying the traffic policy you saved in the previous step with the `--traffic-policy-file` flag: + +``` +$ ngrok http 80 --traffic-policy-file policy.yml +``` + +This command starts an HTTP tunnel for port `80`, using the specified `policy.yml` traffic policy to manage traffic. + +## Step 3: Test it out + +After running the ngrok command in the previous step you should now see a URL in the forwarding section. Open the URL +in your web browser. You should see the "Hello, World!" message displayed in your browser. + +# Next Steps + +**🎉 Congratulations!** + +You've successfully set up your first endpoint with a custom traffic policy using the ngrok agent. + +To learn more about ngrok's Traffic Policy and it's capabilities, check out the following resources: + +- Learn about the [core concepts](/docs/traffic-policy/concepts/) like phases and rules. +- Check out the [examples, use-cases and guides](/docs/traffic-policy/gallery/). +- The list of [available actions](/docs/traffic-policy/actions/), [macros](/docs/traffic-policy/macros/) and [variables](/docs/traffic-policy/variables/) you can use.