Form Input

Description

form-input-nginx-module - an NGINX module that reads HTTP POST and PUT request body encoded in application/x-www-form-urlencoded, and parses the arguments in request body into NGINX variables.

This module depends on the ngx_devel_kit (NDK) module.

Installation

  1. Get the NGINX source code from nginx.org.
  2. Get the ngx_devel_kit source code from GitHub simpl-it/ngx_devel_kit repository
  3. Unpack the source code and build NGINX with this module.
$ wget 'http://sysoev.ru/nginx/nginx-0.8.28.tar.gz'
$ tar -xzvf nginx-0.8.28.tar.gz
$ cd nginx-0.8.28/

$ git-clone http://github.com/simpl-it/ngx_devel_kit.git
$ git-clone http://github.com/calio/form-input-nginx-module.git

$ ./configure --add-module=/somepath/form-input-nginx-module --add-module=/somepath/ngx_devel_kit
$ make -j2
$ make install

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 {
  set_form_input $data;     # read "data" field into $data
  set_form_input $foo foo;  # read "foo" field into $foo
}
location /bar {
  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 a string
  array_join ' ' $foo;             # now $foo is a string
}

Compatibility

The following versions of NGINX should work with this module:

  • 0.8.x <= 0.8.41 (last tested version is 0.8.43)
  • 0.7.x (last tested version is 0.7.67)

Changelog

Changes with form-input-module v0.0.2

  • Supports set_form_input_multi
  • Supports PUT method

Changes with form-input-module v0.0.1

  • Supports set_form_input