form-input: NGINX form input module
Debian/Ubuntu installation
These docs apply to the APT package nginx-module-form-input provided by the GetPageSpeed Extras repository.
- Configure the APT repository as described in APT repository setup.
- Install the module:
sudo apt-get update
sudo apt-get install nginx-module-form-input
Show suites and architectures
| Distro | Suite | Component | Architectures |
|----------|-------------------|-------------|-----------------|
| debian | bookworm | main | amd64, arm64 |
| debian | bookworm-mainline | main | amd64, arm64 |
| debian | trixie | main | amd64, arm64 |
| debian | trixie-mainline | main | amd64, arm64 |
| ubuntu | focal | main | amd64, arm64 |
| ubuntu | focal-mainline | main | amd64, arm64 |
| ubuntu | jammy | main | amd64, arm64 |
| ubuntu | jammy-mainline | main | amd64, arm64 |
| ubuntu | noble | main | amd64, arm64 |
| ubuntu | noble-mainline | main | amd64, arm64 |
form-input-nginx-module - NGINX module that reads HTTP POST and PUT request body encoded in "application/x-www-form-urlencoded" and parses the arguments into nginx variables.
Description
This is a nginx module that reads HTTP POST and PUT request body encoded in "application/x-www-form-urlencoded", and parse the arguments in request body into nginx variables.
This module depends on the ngx_devel_kit (NDK) module.
Usage
set_form_input $variable;
set_form_input $variable argument;
set_form_input_multi $variable;
set_form_input_multi $variable argument;
example:
#nginx.conf
location /foo {
# ensure client_max_body_size == client_body_buffer_size
client_max_body_size 100k;
client_body_buffer_size 100k;
set_form_input $data; # read "data" field into $data
set_form_input $foo foo; # read "foo" field into $foo
}
location /bar {
# ensure client_max_body_size == client_body_buffer_size
client_max_body_size 1m;
client_body_buffer_size 1m;
set_form_input_multi $data; # read all "data" field into $data
set_form_input_multi $foo data; # read all "data" field into $foo
array_join ' ' $data; # now $data is an string
array_join ' ' $foo; # now $foo is an string
}
Limitations
- ngx_form_input will discard request bodies that are buffered to disk files. When the client_max_body_size setting is larger than client_body_buffer_size, request bodies that are larger than client_body_buffer_size (but no larger than client_max_body_size) will be buffered to disk files. So it's important to ensure these two config settings take the same values to avoid confustion.