Skip to content

Commit

Permalink
doc(http): Add specific HTTP configuration documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ldebruijn committed Oct 17, 2024
1 parent 1cddb9f commit 697e9fb
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 27 deletions.
6 changes: 5 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ Protect supports various running modes for different needs and purposes.
* `validate` runs as a CLI tool, validating your Persisted Operations against your schema and configured protections (see [this page](configuration.md#graphql-protect---validate-run-mode) for more info how to set this up)
* `version` outputs versioning info of protect

## HTTP configuration

* [HTTP Configuration](http.md)
*
## Protections

This section contains all the documentation about each protection feature.

* [Persisted Operations](protections/trusted_documents)
* [Persisted Operations](protections/trusted_documents.md)
* [Block Field Suggestions](protections/block_field_suggestions.md)
* [Max Aliases](protections/max_aliases.md)
* [Max Tokens](protections/max_tokens.md)
Expand Down
38 changes: 12 additions & 26 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,32 @@ The following outlines the structure of the yaml, as well as outlines the **defa

```yaml
web:
# Maximum duration to read the entire request
read_timeout: 5s
# Maximum duration before timing out writes of the response
write_timeout: 10s
# Maximum time to wait between idle requests for keep alive
idle_timeout: 120s
# Time to wait until forcibly shutting down protect, after receiving a shutdown signal
shutdown_timeout: 20s
# host and port to listen on
host: 0.0.0.0:8080
# path that receives GraphQL traffic
path: /graphql
# limit the maximum size of a request body that is allowed
# this helps prevent OOM attacks through excessively large request payloads.
# A limit of `0` disables this protection.
request_body_max_bytes: 102400

target:
# Target host and port to send traffic to after validating
host: http://localhost:8081
# Dial timeout waiting for a connection to complete with the target upstream
timeout: 10s
# Interval of keep alive probes
keep_alive: 180s
target:
tracing:
# Headers to redact when sending tracing information
redacted_headers: []

schema:
Expand Down Expand Up @@ -170,28 +180,4 @@ max_batch:
enabled: true
# The maximum number of operations within a single batched request.
max: 5
```
## HTTP Request Body Max Byte size
To prevent OOM attacks through excessively large request bodies, a default limit is posed on request body size of `100kb`. This limit is generally speaking ample space for GraphQL request bodies, while also providing solid protections.

You can modify this limit by changing the following configuration option

```yaml
web:
# limit the maximum size of a request body that is allowed
# this helps prevent OOM attacks through excessively large request payloads.
# A limit of `0` disables this protection.
request_body_max_bytes: 102400
```
### Metrics
A metric is exposed to track if and when a request is rejected that exceeds this limit.
```
graphql_protect_http_request_max_body_bytes_exceeded_count{}
```

No metrics are produced for requests that do not exceed this limit.
```
58 changes: 58 additions & 0 deletions docs/http.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# HTTP Configuration

## HTTP server configuration

```yaml
web:
# Maximum duration to read the entire request
read_timeout: 5s
# Maximum duration before timing out writes of the response
write_timeout: 10s
# Maximum time to wait between idle requests for keep alive
idle_timeout: 120s
# Time to wait until forcibly shutting down protect, after receiving a shutdown signal
shutdown_timeout: 20s
# host and port to listen on
host: 0.0.0.0:8080
# path that receives GraphQL traffic
path: /graphql
# limit the maximum size of a request body that is allowed
# this helps prevent OOM attacks through excessively large request payloads.
# A limit of `0` disables this protection.
request_body_max_bytes: 102400

target:
# Target host and port to send traffic to after validating
host: http://localhost:8081
# Dial timeout waiting for a connection to complete with the target upstream
timeout: 10s
# Interval of keep alive probes
keep_alive: 180s
tracing:
# Headers to redact when sending tracing information
redacted_headers: []
```
## HTTP Request Body Max Byte size
To prevent OOM attacks through excessively large request bodies, a default limit is posed on request body size of `100kb`. This limit is generally speaking ample space for GraphQL request bodies, while also providing solid protections.

You can modify this limit by changing the following configuration option

```yaml
web:
# limit the maximum size of a request body that is allowed
# this helps prevent OOM attacks through excessively large request payloads.
# A limit of `0` disables this protection.
request_body_max_bytes: 102400
```
### Metrics
A metric is exposed to track if and when a request is rejected that exceeds this limit.
```
graphql_protect_http_request_max_body_bytes_exceeded_count{}
```

No metrics are produced for requests that do not exceed this limit.

0 comments on commit 697e9fb

Please sign in to comment.