This is my first nginx test module for understanding nginx module development.
A nginx module to compare the value of user-defined variables and request.
- nginx
- 1.7.x (last tested: 1.7.8)
- 1.6.x (last tested: 1.6.2)
Earlier versions is not tested.
- Clone the git repository.
shell> git clone git://github.com/vozlt/nginx-module-udc.git
-
Add the module to the build configuration by adding
--add-module=/path/to/nginx-module-udc
-
Build the nginx binary.
-
Install the nginx binary.
location /user-define-check {
user_define_check;
user_define_check_out_type json;
user_define_check_allow_text "true";
user_define_check_deny_text "false";
user_define_check_agent "USER_DEFINED_0";
user_define_check_agent "USER_DEFINED_1";
user_define_check_agent "USER_DEFINED_2";
}
This is an Nginx module that compare the value of user-defined variables and value of request. This module returns the compared result to string that is specific type.
The types as follows:
- JSON
- TEXT
- | - |
---|---|
Syntax | user_define_check |
Default | - |
Context | server, location |
Description: Enables or disables user_define_check function.
- | - |
---|---|
Syntax | user_define_check_out_type [json|text] |
Default | json |
Context | server, location |
Description: The output type of result.
- | - |
---|---|
Syntax | user_define_check_allow_text <user-defined-string> |
Default | true |
Context | server, location |
Description: The string of success result.
- | - |
---|---|
Syntax | user_define_check_deny_text <user-defined-string> |
Default | false |
Context | server, location |
Description: The string of failure result.
- | - |
---|---|
Syntax | user_define_check_agent <user-defined-string> |
Default | - |
Context | server, location |
Description: The string to check.
shell> (echo -en "GET /user-define-check?USER_DEFINED_0 HTTP/1.1\r\nHost:localhost\r\n\r\n"; sleep 1) | nc localhost 80
{"status":"true"}
shell> (echo -en "GET /user-define-check?USER_DEFINED_3 HTTP/1.1\r\nHost:localhost\r\n\r\n"; sleep 1) | nc localhost 80
{"status":"false"}
YoungJoo.Kim [vozltx@gmail.com]