Description

This module extends the standard HttpRewriteModule's directive set to provide more functionalities like URI escaping and unescaping, JSON quoting, Hexadecimal/MD5/SHA1/Base32/Base64 digest encoding and decoding, random number generator, and more!

set_quote_sql_str

syntax:set_quote_sql_str $dst <src>

syntax:set_quote_sql_str $dst

default:no

context:location, location if

phase:rewrite

category:ndk_set_var_value

When taking two arguments, this directive will quote the value of the second argument <src> by MySQL's string value quoting rule and assign the result into the first argument, variable $dst. For example,

set_decode_hex

Similar to the set_encode_hex directive, but does exactly the the opposite operation, .i.e, decoding a hexadecimal digest into its original form.

set_sha1

syntax:set_sha1 $dst <src>

syntax:set_sha1 $dst

default:no

context:location, location if

phase:rewrite

category:ndk_set_var_value

When taking two arguments, this directive will encode the value of the second argument <src> to its SHA-1 digest and assign the result into the first argument, variable $dst. The hexadecimal form of the SHA-1 digest will be generated automatically, use set_decode_hex to decode the result if you want the binary form of the SHA-1 digest.

set_md5

syntax:set_md5 $dst <src>

syntax:set_md5 $dst

default:no

context:location, location if

phase:rewrite

category:ndk_set_var_value

When taking two arguments, this directive will encode the value of the second argument <src> to its MD5 digest and assign the result into the first argument, variable $dst. The hexadecimal form of the MD5 digest will be generated automatically, use set_decode_hex to decode the result if you want the binary form of the MD5 digest.

set_rotate

Increments $value but keeps it in range from <from> to <to>.
If $value is greater than <to> or less than <from> is will be
set to <from> value.

The current value after running this directive will always be saved on a per-location basis. And the this saved value will be used for incrementation when the $value is not initialized or has a bad value.

Only non-negative numbers are allowed for the <from> and <to> arguments.

When <from> is greater than <to>, their values will be exchanged accordingly.

Behind the scene, this directive utilizes the ngx_time API in the Nginx core, so usually no syscall is involved due to the time caching mechanism in the Nginx core.

set_formatted_gmt_time

syntax:set_formatted_gmt_time $res <time-format>

default:no

context:location, location if

phase:rewrite

Set a formatted GMT time to variable $res (as the first argument) using the format string in the second argument.

All the conversion specification notations in the standard C function strftime are supported, like %Y (for 4-digit years) and %M (for minutes in decimal). See http://linux.die.net/man/3/strftime for a complete list of conversion specification symbols.

set_formatted_local_time

Set a formatted local time to variable $res (as the first argument) using the format string in the second argument.

All the conversion specification notations in the standard C function strftime are supported, like %Y (for 4-digit years) and %M (for minutes in decimal). See http://linux.die.net/man/3/strftime for a complete list of conversion specification symbols.

You need to terminate any Nginx processes before running the test suite if you have changed the Nginx server binary.

Because a single nginx server (by default, localhost:1984) is used across all the test scripts (.t files), it's meaningless to run the test suite in parallel by specifying -jN when invoking the prove utility.

Getting involved

You'll be very welcomed to submit patches to the author or just ask for a commit bit to the source repository on GitHub.

Author

Yichun Zhang (agentzh) <agentzh@gmail.com>, CloudFlare Inc.

This wiki page is also maintained by the author himself, and everybody is encouraged to improve this page as well.

Copyright & License

Copyright (C) 2009-2013, Yichun Zhang (章亦春) <agentzh@gmail.com>.

This module is licensed under the terms of the BSD license.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.