Skip to content

Commit

Permalink
feat: getting-started rough draft
Browse files Browse the repository at this point in the history
  • Loading branch information
nijikokun committed Oct 30, 2024
1 parent 29f93b1 commit a9470b4
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions docs/traffic-policy/getting-started.mdx
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit a9470b4

Please sign in to comment.