-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |