Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Traffic Policy module docs #561

Merged
merged 67 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
b84142f
automated generation of docs from buildkite
Jan 31, 2024
cb56c04
starting to piece together some documentation scaffolding for http en…
rkolavo Jan 17, 2024
ebcf8b3
more examples, copypasta to tcp/tls
rkolavo Jan 17, 2024
614e4b8
prettier
rkolavo Jan 17, 2024
7c538e3
rename to traffic policy
rkolavo Jan 19, 2024
43819bd
more examples + rewording
rkolavo Jan 22, 2024
6711872
sidebar for api changes
rkolavo Jan 22, 2024
f051f28
prettier
rkolavo Jan 22, 2024
1b81a2b
Add log details
rkolavo Jan 22, 2024
56e6a84
feat: add expressions header and move macro examples out of the table
nijikokun Jan 22, 2024
a2a1e69
fix: prettier
nijikokun Jan 22, 2024
c57ad26
feat: clean up expressions docs for TLS/TCP/HTTP
nijikokun Jan 22, 2024
eb2752a
remove rate-limiting from tcp/tls
rkolavo Jan 22, 2024
2711657
prettier
rkolavo Jan 22, 2024
b1158b3
incorporate url-rewrite doc, cleanup/rename
rkolavo Jan 30, 2024
84c54b9
prettier
rkolavo Jan 31, 2024
4a2d565
fix sidebar for renamed pages
rkolavo Jan 31, 2024
1d4315e
more renames
rkolavo Jan 31, 2024
abcebef
formatting and adding rate limit details
rkolavo Jan 31, 2024
e4f12a7
rate limiting docs
natasha-jarus Jan 31, 2024
bd3f1f5
--policy-config is --policy-file
rkolavo Feb 1, 2024
cb4cc25
feat: add action config examples
nijikokun Feb 2, 2024
d04d36a
go sdk examples
rkolavo Feb 2, 2024
984c62d
tabify
rkolavo Feb 2, 2024
291bc3a
add python examples, prettierrrrr
rkolavo Feb 2, 2024
709ea6d
Add policy action doc (#582)
wdawson Feb 6, 2024
116e290
feat(traffic-policy): use configexample for expressions
nijikokun Feb 6, 2024
95c62e6
docs(jwt): add JWKS definition
nijikokun Feb 6, 2024
22c31dc
docs(jwt): teh -> the
nijikokun Feb 6, 2024
ebc138f
docs(traffic-policy): use configexample for expressions
nijikokun Feb 6, 2024
5200655
update macros examples
benjaminchan Feb 6, 2024
b7e4d59
update go-sdk examples, add javascript and k8s examples
rkolavo Feb 7, 2024
84da0ca
more k8s examples
rkolavo Feb 7, 2024
2578b1b
feat: adding jwt action guide for auth0
russorat Feb 9, 2024
525be48
fix: example typo
russorat Feb 9, 2024
8560c28
fix: addressing pr comments
russorat Feb 9, 2024
c883879
fix: addressing more pr comments
russorat Feb 9, 2024
43745b7
fix: use yaml for json
nijikokun Feb 13, 2024
dfa8fd1
feat: add rule gallery for http, various fixes
nijikokun Feb 13, 2024
7c5c412
custom-response: update configuration (#598)
TheConcierge Feb 14, 2024
d9200a6
chore: update docs for rate-limit action
nijikokun Feb 14, 2024
b762005
fix: check against nil
nijikokun Feb 15, 2024
c312334
fix: check len
nijikokun Feb 15, 2024
b9937cb
fix: use size
nijikokun Feb 15, 2024
d02a49b
fix: not in
nijikokun Feb 15, 2024
1733c7a
add documentation for cidr macros (#599)
benjaminchan Feb 16, 2024
8e8e69b
docs(agent): changelog for 3.6.0 (#581)
nijikokun Feb 7, 2024
214fecc
Adding 3.6 to version support policy
salilsub Feb 7, 2024
9691a2a
Fixing reversion on the docs
salilsub Feb 8, 2024
e8aca35
Create limits guide
samcrichard Feb 6, 2024
adbfa94
Update limits
samcrichard Feb 6, 2024
500b903
fix: clean up and adding to guide index
russorat Feb 8, 2024
b1f4d0a
fix: broken link
russorat Feb 8, 2024
68c6c2a
Update limits.md
samcrichard Feb 8, 2024
7680b9b
runs fmt
cody-dot-js Feb 8, 2024
b6da1b3
Adding links to the setup and installation pages in the dashboard
salilsub Feb 5, 2024
8f295f3
Add integration how-to guide: Ingress to apps deployed on Azure Kuber…
joelhans Feb 9, 2024
620472a
Update limits.md
samcrichard Feb 9, 2024
38a93dd
feat: initial traffic inspector docs
russorat Feb 9, 2024
ff99574
Fixing broken link
salilsub Feb 12, 2024
d0cb906
Remove JWT Validation Module entirely because docs pipeliene doesn't.…
wdawson Feb 13, 2024
b287444
feat: adding orb to webhook verification
russorat Feb 15, 2024
60aa101
feat: initial whats new
russorat Feb 3, 2024
7158ff3
feat: adding whats new page
russorat Feb 10, 2024
1983e49
fix: adding more stuff
russorat Feb 15, 2024
1b745cd
fix: fmt
russorat Feb 15, 2024
2ac863c
Merge branch 'main' into rk/policy-module-docs
nijikokun Feb 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add python examples, prettierrrrr
  • Loading branch information
rkolavo committed Feb 7, 2024
commit 291bc3a8379da3ac1685a228ecc8bad7ba17448a
28 changes: 14 additions & 14 deletions docs/agent/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -508,20 +508,20 @@ ngrok tcp --remote-addr=1.tcp.ngrok.io:27210 3389

### Flags

| Flag | Description |
| ------------------------ | --------------------------------------------------------------------------------------------------------- |
| `--authtoken string` | ngrok authtoken |
| `--cidr-allow strings` | reject connections that do not match the given CIDRs |
| `--cidr-deny strings` | reject connections that match the given CIDRs |
| `--config strings` | path to config files; they are merged if multiple |
| `-h`, `--help` | help for this command |
| `--log string` | path to log file, `stdout`, `stderr` or `false` (default `false`) |
| `--log-format string` | log record format: `term`, `logfmt`, `json` (default `term`) |
| `--log-level string` | `debug`, `info`, `warn`, `error`, `crit` (default `info`) |
| `--policy-file string` | path to traffic policy configuration YAML file (See [Traffic Policy](/tcp/traffic-policy/?cty=agent-cli)) |
| `--proxy-proto string` | version of proxy proto to use with this tunnel, empty if not using |
| `--region string` | ngrok server region `us`, `us-cal-1`, `eu`, `au`, `ap`, `sa`, `jp`, `in` (default to closest) |
| `--remote-addr string` | bind remote address (requires you reserve a TCP Address) |
| Flag | Description |
| ---------------------- | --------------------------------------------------------------------------------------------------------- |
| `--authtoken string` | ngrok authtoken |
| `--cidr-allow strings` | reject connections that do not match the given CIDRs |
| `--cidr-deny strings` | reject connections that match the given CIDRs |
| `--config strings` | path to config files; they are merged if multiple |
| `-h`, `--help` | help for this command |
| `--log string` | path to log file, `stdout`, `stderr` or `false` (default `false`) |
| `--log-format string` | log record format: `term`, `logfmt`, `json` (default `term`) |
| `--log-level string` | `debug`, `info`, `warn`, `error`, `crit` (default `info`) |
| `--policy-file string` | path to traffic policy configuration YAML file (See [Traffic Policy](/tcp/traffic-policy/?cty=agent-cli)) |
| `--proxy-proto string` | version of proxy proto to use with this tunnel, empty if not using |
| `--region string` | ngrok server region `us`, `us-cal-1`, `eu`, `au`, `ap`, `sa`, `jp`, `in` (default to closest) |
| `--remote-addr string` | bind remote address (requires you reserve a TCP Address) |

## ngrok tls

Expand Down
2 changes: 1 addition & 1 deletion docs/http/traffic-policy/actions/deny.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ If this action is executed, no further actions or policy rules in the policy con

| Parameter |   | Description |
| ------------- | ------ | ---------------------------------------------------------------------- |
| `status_code` | int | The status code of the response. If not specified, `999` will be used. |
| `status_code` | int | The status code of the response. If not specified, `999` will be used. |
14 changes: 7 additions & 7 deletions docs/http/traffic-policy/actions/rate-limit.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ Currently, the `capacity` for each bucket is applied per ingress server.
| ------------ |
| `rate-limit` |

| Parameter |   | Description |
| ------------ | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `name` | string | A name for this rate limit configuration. |
| `algorithm` | string | The rate limit algorithm to be used. Supported options: `"sliding_window"` |
| `capacity` | uint | The maximum number of requests allowed to reach your upstream server. The minimum capacity is `1` and the maximum capacity is `2,000,000,000`. |
| `rate` | string | The duration in which events may be limited based on the current capacity. This must be specified as a time duration that is a multiple of ten seconds (e.g. `"90s"`, `"10m"`). The minimum value is `"60s"` and the maximum value is `"24h"`. |
| `bucket_key` | Set<string> | The elements of this collection define the unique key of a request to collect and track the rate at which the capacity is being met. Possible values are `"domain"`, which is the Host, `"client_ip"`, and `"req.getHeader('X-example-header-name')"`, which is the value for the specified header key, if it exists. Up to ten bucket keys can be specified. |
| Parameter |   | Description |
| ------------ | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `name` | string | A name for this rate limit configuration. |
| `algorithm` | string | The rate limit algorithm to be used. Supported options: `"sliding_window"` |
| `capacity` | uint | The maximum number of requests allowed to reach your upstream server. The minimum capacity is `1` and the maximum capacity is `2,000,000,000`. |
| `rate` | string | The duration in which events may be limited based on the current capacity. This must be specified as a time duration that is a multiple of ten seconds (e.g. `"90s"`, `"10m"`). The minimum value is `"60s"` and the maximum value is `"24h"`. |
| `bucket_key` | Set<string> | The elements of this collection define the unique key of a request to collect and track the rate at which the capacity is being met. Possible values are `"domain"`, which is the Host, `"client_ip"`, and `"req.getHeader('X-example-header-name')"`, which is the value for the specified header key, if it exists. Up to ten bucket keys can be specified. |
23 changes: 12 additions & 11 deletions examples/actions/custom-response.mdx
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import ConfigExample from '../../src/components/ConfigExample.tsx';
import ConfigExample from "../../src/components/ConfigExample.tsx";

export const type = 'custom-response'
export const type = "custom-response";
export const config = {
status_code: 400,
content_type: "application/json",
content: JSON.stringify({
error: {
message: "Bad Request"
}
})
}
status_code: 400,
content_type: "application/json",
content: JSON.stringify({
error: {
message: "Bad Request",
},
}),
};

export const ExampleHTTP = () => (
<ConfigExample config={{ actions: [{ type, config }] }} />
)

)
18 changes: 9 additions & 9 deletions examples/actions/deny.mdx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import ConfigExample from '../../src/components/ConfigExample.tsx';
import ConfigExample from "../../src/components/ConfigExample.tsx";

export const type = 'deny'
export const type = "deny";
export const config = {
status_code: 404
}
status_code: 404,
};

export const ExampleHTTP = () => (
<ConfigExample config={{ actions: [{ type, config }] }} />
)
<ConfigExample config={{ actions: [{ type, config }] }} />
);

export const ExampleTLS = () => (
<ConfigExample config={{ actions: [{ type }] }} />
)
<ConfigExample config={{ actions: [{ type }] }} />
);

export const ExampleTCP = ExampleTLS
export const ExampleTCP = ExampleTLS;
24 changes: 12 additions & 12 deletions examples/actions/log.mdx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import ConfigExample from '../../src/components/ConfigExample.tsx';
import ConfigExample from "../../src/components/ConfigExample.tsx";

export const type = 'log'
export const type = "log";
export const config = {
metadata: {
message: "Invalid TLS Version",
edge_id: "edghts_2bhsN2VP8W4pTkaMSrhyj0SRf8J",
edge_route_id: "edghtsrt_2bhsN5u05QQ1MRrI3XbpDQMFSE7"
}
}
metadata: {
message: "Invalid TLS Version",
edge_id: "edghts_2bhsN2VP8W4pTkaMSrhyj0SRf8J",
edge_route_id: "edghtsrt_2bhsN5u05QQ1MRrI3XbpDQMFSE7",
},
};

export const ExampleHTTP = () => (
<ConfigExample config={{ actions: [{ type, config }] }} />
)
<ConfigExample config={{ actions: [{ type, config }] }} />
);

export const ExampleTLS = ExampleHTTP
export const ExampleTCP = ExampleHTTP
export const ExampleTLS = ExampleHTTP;
export const ExampleTCP = ExampleHTTP;
19 changes: 10 additions & 9 deletions examples/actions/rate-limit.mdx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import ConfigExample from '../../src/components/ConfigExample.tsx';
import ConfigExample from "../../src/components/ConfigExample.tsx";

export const type = 'rate-limit'
export const type = "rate-limit";
export const config = {
name: "Only allow 30 requests per minute",
algorithm: "sliding_window",
capacity: 30,
rate: "60s",
bucket_key: ["req.getHeader('x-api-key')"]
}
name: "Only allow 30 requests per minute",
algorithm: "sliding_window",
capacity: 30,
rate: "60s",
bucket_key: ["req.getHeader('x-api-key')"],
};

export const ExampleHTTP = () => (
<ConfigExample config={{ actions: [{ type, config }] }} />
)

)
13 changes: 7 additions & 6 deletions examples/actions/url-rewrite.mdx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import ConfigExample from '../../src/components/ConfigExample.tsx';
import ConfigExample from "../../src/components/ConfigExample.tsx";

export const type = 'url-rewrite'
export const type = "url-rewrite";
export const config = {
from: 'v0/user/([0-9]+).*',
to: 'v1/user?id=$1&$args'
}
from: "v0/user/([0-9]+).*",
to: "v1/user?id=$1&$args",
};

export const ExampleHTTP = () => (
<ConfigExample config={{ actions: [{ type, config }] }} />
)

)
8 changes: 3 additions & 5 deletions examples/agent-cli/http-traffic-policy.mdx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
```bash
ngrok http 80 --policy-file /path/to/policy-config.yml
ngrok http 80 --policy-file /path/to/policy.yml
```

```yaml
# policy-config.yml

```yaml title="policy.yml"
inbound:
- name: FooBarParamNotFound
expressions:
Expand All @@ -26,7 +24,7 @@ inbound:
actions:
- type: deny
outbound:
- name: "LogUnsuccesfulRequests"
- name: "LogUnsuccessfulRequests"
actions:
- type: log
config:
Expand Down
6 changes: 2 additions & 4 deletions examples/agent-cli/tcp-traffic-policy.mdx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
```bash
ngrok tcp 22 --policy-file /path/to/policy-config.yml
ngrok tcp 22 --policy-file /path/to/policy.yml
```

```yaml
# policy-config.yml

```yaml title="policy.yml"
inbound:
- name: "LimitToKnownIPs"
expressions:
Expand Down
6 changes: 2 additions & 4 deletions examples/agent-cli/tls-traffic-policy.mdx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
```bash
ngrok tls 80 --policy-file /path/to/policy-config.yml
ngrok tls 80 --policy-file /path/to/policy.yml
```

```yaml
# policy-config.yml

```yaml title="policy.yml"
inbound:
- name: "LimitToKnownIPs"
expressions:
Expand Down
81 changes: 41 additions & 40 deletions examples/go-sdk/http-traffic-policy.mdx
Original file line number Diff line number Diff line change
@@ -1,50 +1,51 @@
```go
import (
"context"
"net"
"context"
"net"

"golang.ngrok.com/ngrok"
"golang.ngrok.com/ngrok/config"
"golang.ngrok.com/ngrok"
"golang.ngrok.com/ngrok/config"
)

func ngrokListener(ctx context.Context) (net.Listener, error) {
return ngrok.Listen(ctx,
config.HTTPEndpoint(
config.WithPolicy(
config.WithInboundRules(
config.WithPolicyRule(
config.WithPolicyName("FooBarParamNotFound"),
config.WithPolicyExpression("'bar' in getQueryParam('foo)"),
config.WithPolicyAction(
config.WithPolicyActionType("custom-response"),
config.WithPolicyActionConfig(`{"status_code":404,"content_type":"text/plain","content":"not found"}`),
),
),
config.WithPolicyRule(
config.WithPolicyName("BazCookieForLargeRequests"),
config.WithPolicyExpression("!hasReqCookie('baz')"),
config.WithPolicyExpression("req.ContentLength > 5000"),
config.WithPolicyAction(
config.WithPolicyActionType("deny"),
),
),
),
config.WithOutboundRules(
config.WithPolicyRule(
config.WithPolicyName("LogUnsuccessfulRequests"),
config.WithPolicyExpression("res.StatusCode < '200' && res.StatusCode >= '300'"),
config.WithPolicyAction(
config.WithPolicyActionType("log"),
config.WithPolicyActionConfig(`{"metadata":{"hostport":"example.com:443","success":false}}`),
),
),
),
),
),
ngrok.WithAuthtokenFromEnv(),
)
return ngrok.Listen(ctx,
config.HTTPEndpoint(
config.WithPolicy(
config.WithInboundRules(
config.WithPolicyRule(
config.WithPolicyName("FooBarParamNotFound"),
config.WithPolicyExpression("'bar' in getQueryParam('foo)"),
config.WithPolicyAction(
config.WithPolicyActionType("custom-response"),
config.WithPolicyActionConfig(`{"status_code":404,"content_type":"text/plain","content":"not found"}`),
),
),
config.WithPolicyRule(
config.WithPolicyName("BazCookieForLargeRequests"),
config.WithPolicyExpression("!hasReqCookie('baz')"),
config.WithPolicyExpression("req.ContentLength > 5000"),
config.WithPolicyAction(
config.WithPolicyActionType("deny"),
),
),
),
config.WithOutboundRules(
config.WithPolicyRule(
config.WithPolicyName("LogUnsuccessfulRequests"),
config.WithPolicyExpression("res.StatusCode < '200' && res.StatusCode >= '300'"),
config.WithPolicyAction(
config.WithPolicyActionType("log"),
config.WithPolicyActionConfig(`{"metadata":{"hostport":"example.com:443","success":false}}`),
),
),
),
),
),
ngrok.WithAuthtokenFromEnv(),
)
}
```

Go Package Docs:

- [https://pkg.go.dev/golang.ngrok.com/ngrok/config#WithPolicy](https://pkg.go.dev/golang.ngrok.com/ngrok/config#WithPolicy)
- [https://pkg.go.dev/golang.ngrok.com/ngrok/config#WithPolicy](https://pkg.go.dev/golang.ngrok.com/ngrok/config#WithPolicy)
45 changes: 23 additions & 22 deletions examples/go-sdk/tcp-traffic-policy.mdx
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
```go
import (
"context"
"net"
"context"
"net"

"golang.ngrok.com/ngrok"
"golang.ngrok.com/ngrok/config"
"golang.ngrok.com/ngrok"
"golang.ngrok.com/ngrok/config"
)

func ngrokListener(ctx context.Context) (net.Listener, error) {
return ngrok.Listen(ctx,
config.TCPEndpoint(
config.WithPolicy(
config.WithInboundRules(
config.WithPolicyRule(
config.WithPolicyName("LimitToKnownIPs"),
config.WithPolicyExpression("conn.ClientIP != 8.8.8.8"),
config.WithPolicyExpression("conn.ClientIP != 9.9.9.9"),
config.WithPolicyAction(
config.WithPolicyActionType("deny"),
),
),
),
),
),
ngrok.WithAuthtokenFromEnv(),
)
return ngrok.Listen(ctx,
config.TCPEndpoint(
config.WithPolicy(
config.WithInboundRules(
config.WithPolicyRule(
config.WithPolicyName("LimitToKnownIPs"),
config.WithPolicyExpression("conn.ClientIP != 8.8.8.8"),
config.WithPolicyExpression("conn.ClientIP != 9.9.9.9"),
config.WithPolicyAction(
config.WithPolicyActionType("deny"),
),
),
),
),
),
ngrok.WithAuthtokenFromEnv(),
)
}
```

Go Package Docs:

- [https://pkg.go.dev/golang.ngrok.com/ngrok/config#WithPolicy](https://pkg.go.dev/golang.ngrok.com/ngrok/config#WithPolicy)
- [https://pkg.go.dev/golang.ngrok.com/ngrok/config#WithPolicy](https://pkg.go.dev/golang.ngrok.com/ngrok/config#WithPolicy)
Loading