diff --git a/site/content/en/docs/reference/plugins/buffer.md b/site/content/en/docs/reference/plugins/buffer.md new file mode 100644 index 00000000..ca63f509 --- /dev/null +++ b/site/content/en/docs/reference/plugins/buffer.md @@ -0,0 +1,76 @@ +--- +title: Buffer +--- + +## Description + +The `buffer` plugin fully buffers the complete request, by leveraging Envoy's `buffer` filter. It can be used for several purposes, like: + +* Protecting applications from high network latency. +* Some plugins will buffer the whole request, which may trigger a 413 HTTP status code when the max request body size is met. We can set the `maxRequestBytes` larger than `per_connection_buffer_limit_bytes` to increase the max request body size per route. + +## Attribute + +| | | +|-------|---------| +| Type | General | +| Order | Outer | + +## Configuration + +| Name | Type | Required | Validation | Description | +|-----------------|--------|----------|------------|--------------------------------------------------------------------------------------------| +| maxRequestBytes | uint32 | True | | The maximum request body size that the filter will buffer before returning a 413 response. | + +## Usage + +Assumed we have the HTTPRoute below attached to `localhost:10000`, and a backend server listening to port `8080`: + +```yaml +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: default +spec: + parentRefs: + - name: default + namespace: default + rules: + - matches: + - path: + type: PathPrefix + value: / + backendRefs: + - name: backend + port: 8080 +``` + +By applying the configuration below, the request to `http://localhost:10000/` is buffered until the body length meets the max requests bytes 4: + +```yaml +apiVersion: mosn.io/v1 +kind: HTTPFilterPolicy +metadata: + name: policy +spec: + targetRef: + group: gateway.networking.k8s.io + kind: HTTPRoute + name: default + filters: + buffer: + config: + maxRequestBytes: 4 +``` + +We can test it out: + +``` +$ curl -d "hello" http://localhost:10000/ -i +HTTP/1.1 413 Payload Too Large +``` + +``` +$ curl -d "hell" http://localhost:10000/ -i +HTTP/1.1 200 OK +``` diff --git a/site/content/en/docs/reference/plugins/consumer_restriction.md b/site/content/en/docs/reference/plugins/consumer_restriction.md index 6d69ee8c..a3fd0561 100644 --- a/site/content/en/docs/reference/plugins/consumer_restriction.md +++ b/site/content/en/docs/reference/plugins/consumer_restriction.md @@ -17,8 +17,8 @@ The `consumerRestriction` plugin determines whether the current consumer has acc | Name | Type | Required | Validation | Description | |-------|-------|----------|------------|--------------------------------------| -| allow | Rules | No | | List of rules allowing access access | -| deny | Rules | No | | List of rules denying access access | +| allow | Rules | False | | List of rules allowing access access | +| deny | Rules | False | | List of rules denying access access | Only one of `allow` or `deny` can be configured. @@ -26,13 +26,13 @@ Only one of `allow` or `deny` can be configured. | Name | Type | Required | Validation | Description | |-------|--------|----------|----------------|--------------------| -| rules | Rule[] | Yes | min_items: 1 | List of rules | +| rules | Rule[] | True | min_items: 1 | List of rules | ## Rule | Name | Type | Required | Validation | Description | |------|--------|----------|--------------|----------------------| -| name | string | Yes | min_len: 1 | Name of the Consumer | +| name | string | True | min_len: 1 | Name of the Consumer | ## Usage @@ -135,4 +135,4 @@ spec: deny: rules: - name: rick -``` \ No newline at end of file +``` diff --git a/site/content/zh-hans/docs/reference/plugins/buffer.md b/site/content/zh-hans/docs/reference/plugins/buffer.md new file mode 100644 index 00000000..bf944edb --- /dev/null +++ b/site/content/zh-hans/docs/reference/plugins/buffer.md @@ -0,0 +1,75 @@ +--- +title: Buffer +--- + +## 说明 + +`buffer` 插件通过利用 Envoy 的 `buffer` 过滤器完全缓冲整个请求。它可以用于几个目的,比如: + +* 保护应用程序免受高网络延迟的影响。 +* 一些插件会缓冲整个请求。当请求体超过最大长度时,将触发 413 HTTP 状态码。我们可以设置 `maxRequestBytes` 大于 `per_connection_buffer_limit_bytes` 来增加单个路由的最大请求体大小。 + +## 属性 +| | | +|-------|---------| +| Type | General | +| Order | Outer | + +## 配置 + +| 名称 | 类型 | 必选 | 校验规则 | 说明 | +|-----------------|--------|------|----------|-------------------------------------------------------------------------------------| +| maxRequestBytes | uint32 | 是 | | 缓冲的请求体最大大小,超过此大小将返回 413 响应。 | + +## 用法 + +假设我们有下面附加到 `localhost:10000` 的 HTTPRoute,并且有一个后端服务器监听端口 `8080`: + +```yaml +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: default +spec: + parentRefs: + - name: default + namespace: default + rules: + - matches: + - path: + type: PathPrefix + value: / + backendRefs: + - name: backend + port: 8080 +``` + +通过应用下面的配置,发送到 `http://localhost:10000/` 的请求会被缓冲,直到请求体长度达到最大请求字节数 4: + +```yaml +apiVersion: mosn.io/v1 +kind: HTTPFilterPolicy +metadata: + name: policy +spec: + targetRef: + group: gateway.networking.k8s.io + kind: HTTPRoute + name: default + filters: + buffer: + config: + maxRequestBytes: 4 +``` + +我们可以测试一下: + +``` +$ curl -d "hello" http://localhost:10000/ -i +HTTP/1.1 413 Payload Too Large +``` + +``` +$ curl -d "hell" http://localhost:10000/ -i +HTTP/1.1 200 OK +```