Skip to content

Commit

Permalink
Rate limiting
Browse files Browse the repository at this point in the history
  • Loading branch information
S3Prototype committed Feb 7, 2025
1 parent 10d27ff commit 5f6a9b6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 25 deletions.
2 changes: 1 addition & 1 deletion docs/traffic-policy/examples/add-authentication.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Authentication Examples
sidebar_label: Authentication
sidebar_label: Add Authentication
---
import { JWTsRateLimiting } from "/traffic-policy/gallery/JWTsRateLimiting";
import { OAuthConditionalAccess } from "/traffic-policy/gallery/OAuthConditionalAccess";
Expand Down
24 changes: 0 additions & 24 deletions docs/traffic-policy/examples/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,13 @@ import { LogUnsuccessful } from "/traffic-policy/gallery/LogUnsuccessful.tsx";
import { ManipulateHeaders } from "/traffic-policy/gallery/ManipulateHeaders.tsx";
import { OAuthConditionalAccess } from "/traffic-policy/gallery/OAuthConditionalAccess.tsx";
import { OIDCIdentityToken } from "/traffic-policy/gallery/OIDCIdentityToken.tsx";
import { RateLimit } from "/traffic-policy/gallery/RateLimit.tsx";
import { RateLimitAuthentication } from "/traffic-policy/gallery/RateLimitAuthentication.tsx";
import { RateLimitPricing } from "/traffic-policy/gallery/RateLimitPricing.tsx";
import { UserAgentFilter } from "/traffic-policy/gallery/UserAgentFilter.tsx";

Explore a curated collection of examples and configuration examples spanning from common to unconventional use cases for the Traffic Policy module.

A number of these examples come from a longer article about how ngrok [makes policy management accessible](https://ngrok.com/blog-post/api-gateway-policy-management-examples) to developers, including a simple Go-based application for testing these and other configurations.


## Rate limit requests

### Rate limit for specific endpoint

This rule applies rate limiting of `30` requests per second to the endpoint
`/api/videos`.

<RateLimit />

### Rate limit API consumers based on authentication status

Create a low rate limit for unauthenticated (likely free) users, while allowing authenticated users a higher level of capacity.

<RateLimitAuthentication />

### Rate limit API consumers based on pricing tiers

Using a naming scheme in your upstream servers, and API calls using a `tier` header, you can quickly customize access to your API based on any number of pricing tiers.

<RateLimitPricing />

## Block unwanted requests

### Deny traffic from Tor networks
Expand Down
29 changes: 29 additions & 0 deletions docs/traffic-policy/examples/rate-limit-requests.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: Rate Limit Requests Examples
sidebar_label: Rate Limit Requests
---

import { RateLimit } from "/traffic-policy/gallery/RateLimit.tsx";
import { RateLimitAuthentication } from "/traffic-policy/gallery/RateLimitAuthentication.tsx";
import { RateLimitPricing } from "/traffic-policy/gallery/RateLimitPricing.tsx";

With Traffic Policy, you can rate limit requests to your endpoints based on a variety of criteria.

## By endpoint

The following example applies rate limiting of `30` requests per second to the endpoint
`/api/videos`.

<RateLimit />

## Based on authentication status

The following example creates a lower rate limit for unauthenticated (likely free) users, while allowing authenticated users a higher level of capacity.

<RateLimitAuthentication />

## Based on pricing tiers

Using a naming scheme in your upstream servers, and API calls using a `tier` header, you can quickly customize access to your API based on any number of pricing tiers.

<RateLimitPricing />

0 comments on commit 5f6a9b6

Please sign in to comment.