Document updated on Apr 12, 2024
Consumers of the gateway might see their requests limited when using the max_payload
property. All requests are validated when this attribute is set, checking that their size is inside the limits set.
There are two possible placements of this attribute:
You can set both limits simultaneously if you want. When both limits exist, the service level limit is checked first, and if it passes, then it checks the endpoint limit. This means that the endpoint max_payload
must be equal to or smaller than the one at the service. Otherwise, the endpoint limit will never have an opportunity to work.
When users exceed the maximum number of bytes, they get the following status code:
HTTP/1.1 413 Request Entity Too Large
max_payload
in combination with decompress_gzip
when Gzip content goes through KrakenD, it is decompressed in the first place and the maximum payload applies to the decompressed payload.When you want to limit the maximum request size of any request, add the following configuration at the service level under the router
property:
{
"version": 3,
"extra_config": {
"router": {
"max_payload": 1024
}
}
}
The configuration above limits all requests to 1KB (1024 bytes)
"router"
| Enterprise Only. Decompresses any Gzipped content before sending it to the backend when the Content-Encoding has gzip in the first position. You can also set this value per endpoint.Defaults to 0 |
| Enterprise Only. Limits the maximum number of bytes a user can send to the gateway. 0 means no limit. You can also set this value per endpoint.Defaults to 0 |
When you want to limit the maximum payload you can send to an endpoint, place the flag under the proxy
entry of the endpoint. Remember that if you have also set the limit in the router
, that limit will kick in first. This is what you need to add to limit an endpoint:
{
"endpoint": "/body_size",
"method":"POST",
"backend": [
{
"url_pattern": "/__debug/body_size"
}
],
"extra_config":{
"proxy":{
"max_payload": 1024
}
}
}
"proxy"
| Enterprise Only. Decompresses any Gzipped content before sending it to the backend when the Content-Encoding has gzip in the first position. You can also set this value globally at the service level.Defaults to false |
| Enterprise Only. Limits the maximum number of bytes a user can send to the endpoint. 0 means no limit. You can also set this value globally at the service level.Defaults to 0 |
The documentation is only a piece of the help you can get! Whether you are looking for Open Source or Enterprise support, see more support channels that can help you.