The Limit Payload Size solution is a serverless solution available at Azion Marketplace.
The solution employs an edge function to evaluate request data and deny payloads that exceed a predefined limit. The function validates the request payload size by checking the
Content-Length header. The
Content-Length header is required, making it safe to read instead of always reading the body. The users are safeguarded against attempts to change the header’s value in this way, and reading the
Content-Length header is the best course of action from a performance standpoint.
Getting the solutionSection titled Getting the solution
To install the solution, follow these steps:
- Log in to your Real-Time Manager (RTM) account.
- If you don’t have an account, you can create one here.
- On the upper-left corner of the page, select Products menu > Marketplace.
- Select the search box and type “payload” or browse through the cards to find the Limit Payload Size solution.
- Once you’ve found the solution’s card, select it to go to the solution’s page.
- On the solution’s page, look for the Subscribe for section on the bottom-right corner.
- Click the Get It Now button.
After clicking on the Get it now button, you’ll see a message indicating that your solution was successfully installed and is ready to use.
Using the solutionSection titled Using the solution
This is an edge firewall solution, so, you’ll have to instantiate the solution on the Edge Firewall section. Follow the steps below to do this.
Setting up the Edge Firewall ruleSection titled Setting up the Edge Firewall rule
To instantiate the Limit Payload Size solution, follow the steps:
- On the Products menu, select Edge Firewall in the SECURE section.
- Click the Add Rule Set button.
- Give an easy to remember name to your new rule.
- Select the domains you want to protect with the function.
- Click the Function switch to enable functions on your edge application.
- Click the Save button.
Done. Now you have instantiated the rule for your function.
Setting up the Edge Firewall functionSection titled Setting up the Edge Firewall function
To instantiate the Limit Payload Size solution, while still on the Edge Firewall page, select the Functions tab and follow these steps:
- Click the Add Function button.
- Give an easy to remember name to your instance.
- On the dropdown menu, select the Limit Payload Size function.
This action will load the function, showing a form with the function code and, just above it, two tabs: Code and Args. By clicking on the Code tab, you’ll be able to navigate through the code, but not to change it.
For this solution, you only have to pass one argument in the Args JSON file:
Some information about how this solution works:
max_payload_lengthis the maximum size of the payload you’ll accept.
- This field accepts bytes, kilobytes, and megabytes as argument.
- If you don’t specify the unit of the payload size, it’ll be assumed as bytes.
- If you don’t pass any argument, the function will bypass the execution.
- Whenever the size exceeds the threshold set by the user, the solution will return a 403 error.
Setting up the Edge Firewall Rules EngineSection titled Setting up the Edge Firewall Rules Engine
To finish, you have to set up the Rules Engine to configure the behavior and the criteria to run the function.
Still on the Edge Firewall page, select the Rules Engine tab and follow these steps:
- Click the New Rule button.
- Give a name to the rule.
- Select a criteria to run and catch the domain you want to run the solution on.
- Below, select a behavior to the criteria. In this case, it’ll be a Run Function.
- Select the adequate Limit Payload Size function according to the name you gave it in the instantiate step.
- Click the Save button.
Done. Now the Limit Payload Size solution is running for every request made to the domain you indicated.