blob: 64d7319ab8c4aaf2185a253fbe51cec992f13441 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
|
=encoding utf-8
=head1 NAME
ngx_http_map_module - Module ngx_http_map_module
=head1
The C<ngx_http_map_module> module creates variables
whose values depend on values of other variables.
=head1 Example Configuration
map $http_host $name {
hostnames;
default 0;
example.com 1;
*.example.com 1;
example.org 2;
*.example.org 2;
.example.net 3;
wap.* 4;
}
map $http_user_agent $mobile {
default 0;
"~Opera Mini" 1;
}
=head1 Directives
=head2 map
B<syntax:> map I<
I<C<string>>
I<C<$variable>> { B<...> } >
B<context:> I<http>
Creates a new variable whose value
depends on values of one or more of the source variables
specified in the first parameter.
B<NOTE>
Before version 0.9.0 only a single variable could be
specified in the first parameter.
B<NOTE>
Since variables are evaluated only when they are used, the mere declaration
even of a large number of “C<map>” variables
does not add any extra costs to request processing.
Parameters inside the C<map> block specify a mapping
between source and resulting values.
Source values are specified as strings or regular expressions (0.9.6).
Strings are matched ignoring the case.
A regular expression should either start from the “C<~>”
symbol for a case-sensitive matching, or from the “C<~*>”
symbols (1.0.4) 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 “C<\>” symbol.
The resulting value can contain text,
variable (0.9.0), and their combination (1.11.0).
The following special parameters are also supported:
=over
=item C<default> I<C<value>>
sets the resulting value if the source value matches none
of the specified variants.
When C<default> is not specified, the default
resulting value will be an empty string.
=item C<hostnames>
indicates that source values can be hostnames with a prefix or suffix mask:
*.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.
=item C<include> I<C<file>>
includes a file with values.
There can be several inclusions.
=item C<volatile>
indicates that the variable is not cacheable (1.11.7).
=back
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:
=over
=item 1.
string value without a mask
=item 2.
longest string value with a prefix mask,
e.g. “C<*.example.com>”
=item 3.
longest string value with a suffix mask,
e.g. “C<mail.*>”
=item 4.
first matching regular expression
(in order of appearance in a configuration file)
=item 5.
default value
=back
=head2 map_hash_bucket_size
B<syntax:> map_hash_bucket_size I<I<C<size>>>
B<default:> I<32E<verbar>64E<verbar>128>
B<context:> I<http>
Sets the bucket size for the L</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
L<document|hash>.
=head2 map_hash_max_size
B<syntax:> map_hash_max_size I<I<C<size>>>
B<default:> I<2048>
B<context:> I<http>
Sets the maximum I<C<size>> of the L</map> variables
hash tables.
The details of setting up hash tables are provided in a separate
L<document|hash>.
|