The ngx_stream_map_module
module (1.11.2) creates variables whose values depend on values of other variables.
map $remote_addr $limit { 127.0.0.1 ""; default $binary_remote_addr; } limit_conn_zone $limit zone=addr:10m; limit_conn addr 1;
Syntax: | map
string
$variable { ... } |
---|---|
Default: | — |
Context: | stream |
Creates a new variable whose value depends on values of one or more of the source variables specified in the first parameter.
Since variables are evaluated only when they are used, the mere declaration even of a large number of “map
” variables does not add any extra costs to connection processing.
Parameters inside the map
block specify a mapping between source and resulting values.
Source values are specified as strings or regular expressions.
Strings are matched ignoring the case.
A regular expression should either start from the “~
” symbol for a case-sensitive matching, or from the “~*
” symbols for case-insensitive matching. A regular expression can contain named and positional captures that can later be used in other directives along with the resulting variable.
If a source value matches one of the names of special parameters described below, it should be prefixed with the “\
” symbol.
The resulting value can contain text, variable, and their combination.
The following special parameters are also supported:
default
value
default
is not specified, the default resulting value will be an empty string. hostnames
*.example.com 1; example.* 1;The following two records
example.com 1; *.example.com 1;can be combined:
.example.com 1;This parameter should be specified before the list of values.
include
file
volatile
If the source value matches more than one of the specified variants, e.g. both a mask and a regular expression match, the first matching variant will be chosen, in the following order of priority:
*.example.com
” mail.*
” Syntax: | map_hash_bucket_size size; |
---|---|
Default: | map_hash_bucket_size 32|64|128; |
Context: | stream |
Sets the bucket size for the map variables hash tables. Default value depends on the processor’s cache line size. The details of setting up hash tables are provided in a separate document.
Syntax: | map_hash_max_size size; |
---|---|
Default: | map_hash_max_size 2048; |
Context: | stream |
Sets the maximum size
of the map variables hash tables. The details of setting up hash tables are provided in a separate document.
© 2002-2018 Igor Sysoev
© 2011-2018 Nginx, Inc.
Licensed under the BSD License.
https://nginx.org/en/docs/stream/ngx_stream_map_module.html