Skip to content

Latest commit

 

History

History
104 lines (86 loc) · 3.28 KB

client-control.md

File metadata and controls

104 lines (86 loc) · 3.28 KB
title keywords description
client-control
APISIX
API Gateway
Client Control
This document describes the Apache APISIX client-control Plugin, you can use it to control NGINX behavior to handle a client request dynamically.

Description

The client-control Plugin can be used to dynamically control the behavior of NGINX to handle a client request, by setting the max size of the request body.

:::info IMPORTANT

This Plugin requires APISIX to run on APISIX-Base. See apisix-build-tools for more info.

:::

Attributes

Name Type Required Valid values Description
max_body_size integer False [0,...] Dynamically set the client_max_body_size directive.

Enabling the Plugin

The example below enables the Plugin on a specific Route:

curl -i http://127.0.0.1:9180/apisix/admin/routes/1 \
  -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
    "uri": "/index.html",
    "plugins": {
        "client-control": {
            "max_body_size" : 1
        }
    },
    "upstream": {
        "type": "roundrobin",
        "nodes": {
            "127.0.0.1:1980": 1
        }
    }
}'

Example usage

Now since you have configured the max_body_size to 1 above, you will get the following message when you make a request:

curl -i http://127.0.0.1:9080/index.html -d '123'
HTTP/1.1 413 Request Entity Too Large
...
<html>
<head><title>413 Request Entity Too Large</title></head>
<body>
<center><h1>413 Request Entity Too Large</h1></center>
<hr><center>openresty</center>
</body>
</html>

Disable Plugin

To disable the client-control Plugin, you can delete the corresponding JSON configuration from the Plugin configuration. APISIX will automatically reload, and you do not have to restart for this to take effect.

curl http://127.0.0.1:9180/apisix/admin/routes/1  \
  -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
    "uri": "/index.html",
    "upstream": {
        "type": "roundrobin",
        "nodes": {
            "127.0.0.1:1980": 1
        }
    }
}'