0
|
1
|
|
2 /*
|
|
3 * Copyright (C) Igor Sysoev
|
660
|
4 * Copyright (C) Nginx, Inc.
|
0
|
5 */
|
|
6
|
|
7
|
|
8 #include <ngx_config.h>
|
|
9 #include <ngx_core.h>
|
|
10 #include <ngx_http.h>
|
|
11
|
10
|
12
|
180
|
13 typedef struct {
|
286
|
14 u_char *name;
|
180
|
15 uint32_t method;
|
|
16 } ngx_http_method_name_t;
|
|
17
|
|
18
|
278
|
19 #define NGX_HTTP_REQUEST_BODY_FILE_OFF 0
|
|
20 #define NGX_HTTP_REQUEST_BODY_FILE_ON 1
|
|
21 #define NGX_HTTP_REQUEST_BODY_FILE_CLEAN 2
|
|
22
|
|
23
|
378
|
24 static ngx_int_t ngx_http_core_find_location(ngx_http_request_t *r);
|
|
25 static ngx_int_t ngx_http_core_find_static_location(ngx_http_request_t *r,
|
|
26 ngx_http_location_tree_node_t *node);
|
0
|
27
|
58
|
28 static ngx_int_t ngx_http_core_preconfiguration(ngx_conf_t *cf);
|
0
|
29 static void *ngx_http_core_create_main_conf(ngx_conf_t *cf);
|
|
30 static char *ngx_http_core_init_main_conf(ngx_conf_t *cf, void *conf);
|
|
31 static void *ngx_http_core_create_srv_conf(ngx_conf_t *cf);
|
|
32 static char *ngx_http_core_merge_srv_conf(ngx_conf_t *cf,
|
36
|
33 void *parent, void *child);
|
0
|
34 static void *ngx_http_core_create_loc_conf(ngx_conf_t *cf);
|
|
35 static char *ngx_http_core_merge_loc_conf(ngx_conf_t *cf,
|
36
|
36 void *parent, void *child);
|
0
|
37
|
34
|
38 static char *ngx_http_core_server(ngx_conf_t *cf, ngx_command_t *cmd,
|
36
|
39 void *dummy);
|
34
|
40 static char *ngx_http_core_location(ngx_conf_t *cf, ngx_command_t *cmd,
|
36
|
41 void *dummy);
|
430
|
42 static ngx_int_t ngx_http_core_regex_location(ngx_conf_t *cf,
|
|
43 ngx_http_core_loc_conf_t *clcf, ngx_str_t *regex, ngx_uint_t caseless);
|
34
|
44
|
|
45 static char *ngx_http_core_types(ngx_conf_t *cf, ngx_command_t *cmd,
|
36
|
46 void *conf);
|
34
|
47 static char *ngx_http_core_type(ngx_conf_t *cf, ngx_command_t *dummy,
|
36
|
48 void *conf);
|
0
|
49
|
34
|
50 static char *ngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd,
|
36
|
51 void *conf);
|
34
|
52 static char *ngx_http_core_server_name(ngx_conf_t *cf, ngx_command_t *cmd,
|
36
|
53 void *conf);
|
34
|
54 static char *ngx_http_core_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
|
180
|
55 static char *ngx_http_core_limit_except(ngx_conf_t *cf, ngx_command_t *cmd,
|
|
56 void *conf);
|
390
|
57 static char *ngx_http_core_directio(ngx_conf_t *cf, ngx_command_t *cmd,
|
|
58 void *conf);
|
34
|
59 static char *ngx_http_core_error_page(ngx_conf_t *cf, ngx_command_t *cmd,
|
36
|
60 void *conf);
|
430
|
61 static char *ngx_http_core_try_files(ngx_conf_t *cf, ngx_command_t *cmd,
|
|
62 void *conf);
|
332
|
63 static char *ngx_http_core_open_file_cache(ngx_conf_t *cf, ngx_command_t *cmd,
|
|
64 void *conf);
|
34
|
65 static char *ngx_http_core_error_log(ngx_conf_t *cf, ngx_command_t *cmd,
|
36
|
66 void *conf);
|
34
|
67 static char *ngx_http_core_keepalive(ngx_conf_t *cf, ngx_command_t *cmd,
|
36
|
68 void *conf);
|
58
|
69 static char *ngx_http_core_internal(ngx_conf_t *cf, ngx_command_t *cmd,
|
|
70 void *conf);
|
354
|
71 static char *ngx_http_core_resolver(ngx_conf_t *cf, ngx_command_t *cmd,
|
348
|
72 void *conf);
|
358
|
73 #if (NGX_HTTP_GZIP)
|
632
|
74 static ngx_int_t ngx_http_gzip_accept_encoding(ngx_str_t *ae);
|
634
|
75 static ngx_uint_t ngx_http_gzip_quantity(u_char *p, u_char *last);
|
358
|
76 static char *ngx_http_gzip_disable(ngx_conf_t *cf, ngx_command_t *cmd,
|
|
77 void *conf);
|
|
78 #endif
|
664
|
79 #if (NGX_HAVE_OPENAT)
|
|
80 static char *ngx_http_disable_symlinks(ngx_conf_t *cf, ngx_command_t *cmd,
|
|
81 void *conf);
|
|
82 #endif
|
0
|
83
|
34
|
84 static char *ngx_http_core_lowat_check(ngx_conf_t *cf, void *post, void *data);
|
300
|
85 static char *ngx_http_core_pool_size(ngx_conf_t *cf, void *post, void *data);
|
34
|
86
|
|
87 static ngx_conf_post_t ngx_http_core_lowat_post =
|
300
|
88 { ngx_http_core_lowat_check };
|
|
89
|
|
90 static ngx_conf_post_handler_pt ngx_http_core_pool_size_p =
|
|
91 ngx_http_core_pool_size;
|
0
|
92
|
378
|
93 static ngx_conf_deprecated_t ngx_conf_deprecated_optimize_server_names = {
|
|
94 ngx_conf_deprecated, "optimize_server_names", "server_name_in_redirect"
|
158
|
95 };
|
|
96
|
358
|
97 static ngx_conf_deprecated_t ngx_conf_deprecated_open_file_cache_retest = {
|
|
98 ngx_conf_deprecated, "open_file_cache_retest", "open_file_cache_valid"
|
|
99 };
|
|
100
|
362
|
101 static ngx_conf_deprecated_t ngx_conf_deprecated_satisfy_any = {
|
|
102 ngx_conf_deprecated, "satisfy_any", "satisfy"
|
|
103 };
|
|
104
|
0
|
105
|
278
|
106 static ngx_conf_enum_t ngx_http_core_request_body_in_file[] = {
|
|
107 { ngx_string("off"), NGX_HTTP_REQUEST_BODY_FILE_OFF },
|
|
108 { ngx_string("on"), NGX_HTTP_REQUEST_BODY_FILE_ON },
|
|
109 { ngx_string("clean"), NGX_HTTP_REQUEST_BODY_FILE_CLEAN },
|
|
110 { ngx_null_string, 0 }
|
|
111 };
|
|
112
|
|
113
|
520
|
114 #if (NGX_HAVE_FILE_AIO)
|
|
115
|
|
116 static ngx_conf_enum_t ngx_http_core_aio[] = {
|
|
117 { ngx_string("off"), NGX_HTTP_AIO_OFF },
|
|
118 { ngx_string("on"), NGX_HTTP_AIO_ON },
|
|
119 #if (NGX_HAVE_AIO_SENDFILE)
|
|
120 { ngx_string("sendfile"), NGX_HTTP_AIO_SENDFILE },
|
|
121 #endif
|
|
122 { ngx_null_string, 0 }
|
|
123 };
|
|
124
|
|
125 #endif
|
|
126
|
|
127
|
362
|
128 static ngx_conf_enum_t ngx_http_core_satisfy[] = {
|
|
129 { ngx_string("all"), NGX_HTTP_SATISFY_ALL },
|
|
130 { ngx_string("any"), NGX_HTTP_SATISFY_ANY },
|
|
131 { ngx_null_string, 0 }
|
|
132 };
|
|
133
|
|
134
|
632
|
135 static ngx_conf_enum_t ngx_http_core_lingering_close[] = {
|
|
136 { ngx_string("off"), NGX_HTTP_LINGERING_OFF },
|
|
137 { ngx_string("on"), NGX_HTTP_LINGERING_ON },
|
|
138 { ngx_string("always"), NGX_HTTP_LINGERING_ALWAYS },
|
|
139 { ngx_null_string, 0 }
|
|
140 };
|
|
141
|
|
142
|
424
|
143 static ngx_conf_enum_t ngx_http_core_if_modified_since[] = {
|
444
|
144 { ngx_string("off"), NGX_HTTP_IMS_OFF },
|
|
145 { ngx_string("exact"), NGX_HTTP_IMS_EXACT },
|
|
146 { ngx_string("before"), NGX_HTTP_IMS_BEFORE },
|
424
|
147 { ngx_null_string, 0 }
|
|
148 };
|
|
149
|
|
150
|
648
|
151 static ngx_conf_bitmask_t ngx_http_core_keepalive_disable[] = {
|
604
|
152 { ngx_string("none"), NGX_HTTP_KEEPALIVE_DISABLE_NONE },
|
|
153 { ngx_string("msie6"), NGX_HTTP_KEEPALIVE_DISABLE_MSIE6 },
|
|
154 { ngx_string("safari"), NGX_HTTP_KEEPALIVE_DISABLE_SAFARI },
|
|
155 { ngx_null_string, 0 }
|
|
156 };
|
|
157
|
|
158
|
464
|
159 static ngx_path_init_t ngx_http_client_temp_path = {
|
|
160 ngx_string(NGX_HTTP_CLIENT_TEMP_PATH), { 0, 0, 0 }
|
|
161 };
|
|
162
|
|
163
|
358
|
164 #if (NGX_HTTP_GZIP)
|
|
165
|
|
166 static ngx_conf_enum_t ngx_http_gzip_http_version[] = {
|
|
167 { ngx_string("1.0"), NGX_HTTP_VERSION_10 },
|
|
168 { ngx_string("1.1"), NGX_HTTP_VERSION_11 },
|
|
169 { ngx_null_string, 0 }
|
|
170 };
|
|
171
|
|
172
|
|
173 static ngx_conf_bitmask_t ngx_http_gzip_proxied_mask[] = {
|
|
174 { ngx_string("off"), NGX_HTTP_GZIP_PROXIED_OFF },
|
|
175 { ngx_string("expired"), NGX_HTTP_GZIP_PROXIED_EXPIRED },
|
|
176 { ngx_string("no-cache"), NGX_HTTP_GZIP_PROXIED_NO_CACHE },
|
|
177 { ngx_string("no-store"), NGX_HTTP_GZIP_PROXIED_NO_STORE },
|
|
178 { ngx_string("private"), NGX_HTTP_GZIP_PROXIED_PRIVATE },
|
|
179 { ngx_string("no_last_modified"), NGX_HTTP_GZIP_PROXIED_NO_LM },
|
|
180 { ngx_string("no_etag"), NGX_HTTP_GZIP_PROXIED_NO_ETAG },
|
|
181 { ngx_string("auth"), NGX_HTTP_GZIP_PROXIED_AUTH },
|
|
182 { ngx_string("any"), NGX_HTTP_GZIP_PROXIED_ANY },
|
|
183 { ngx_null_string, 0 }
|
|
184 };
|
|
185
|
|
186
|
|
187 static ngx_str_t ngx_http_gzip_no_cache = ngx_string("no-cache");
|
|
188 static ngx_str_t ngx_http_gzip_no_store = ngx_string("no-store");
|
|
189 static ngx_str_t ngx_http_gzip_private = ngx_string("private");
|
|
190
|
|
191 #endif
|
|
192
|
|
193
|
0
|
194 static ngx_command_t ngx_http_core_commands[] = {
|
|
195
|
160
|
196 { ngx_string("variables_hash_max_size"),
|
|
197 NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
|
|
198 ngx_conf_set_num_slot,
|
|
199 NGX_HTTP_MAIN_CONF_OFFSET,
|
|
200 offsetof(ngx_http_core_main_conf_t, variables_hash_max_size),
|
|
201 NULL },
|
|
202
|
|
203 { ngx_string("variables_hash_bucket_size"),
|
|
204 NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
|
|
205 ngx_conf_set_num_slot,
|
|
206 NGX_HTTP_MAIN_CONF_OFFSET,
|
|
207 offsetof(ngx_http_core_main_conf_t, variables_hash_bucket_size),
|
|
208 NULL },
|
|
209
|
142
|
210 { ngx_string("server_names_hash_max_size"),
|
26
|
211 NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
|
|
212 ngx_conf_set_num_slot,
|
|
213 NGX_HTTP_MAIN_CONF_OFFSET,
|
142
|
214 offsetof(ngx_http_core_main_conf_t, server_names_hash_max_size),
|
26
|
215 NULL },
|
|
216
|
142
|
217 { ngx_string("server_names_hash_bucket_size"),
|
26
|
218 NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
|
|
219 ngx_conf_set_num_slot,
|
|
220 NGX_HTTP_MAIN_CONF_OFFSET,
|
142
|
221 offsetof(ngx_http_core_main_conf_t, server_names_hash_bucket_size),
|
26
|
222 NULL },
|
|
223
|
0
|
224 { ngx_string("server"),
|
682
|
225 NGX_HTTP_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
|
34
|
226 ngx_http_core_server,
|
0
|
227 0,
|
|
228 0,
|
|
229 NULL },
|
|
230
|
|
231 { ngx_string("connection_pool_size"),
|
|
232 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
|
|
233 ngx_conf_set_size_slot,
|
|
234 NGX_HTTP_SRV_CONF_OFFSET,
|
|
235 offsetof(ngx_http_core_srv_conf_t, connection_pool_size),
|
300
|
236 &ngx_http_core_pool_size_p },
|
0
|
237
|
|
238 { ngx_string("request_pool_size"),
|
|
239 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
|
|
240 ngx_conf_set_size_slot,
|
|
241 NGX_HTTP_SRV_CONF_OFFSET,
|
|
242 offsetof(ngx_http_core_srv_conf_t, request_pool_size),
|
300
|
243 &ngx_http_core_pool_size_p },
|
0
|
244
|
|
245 { ngx_string("client_header_timeout"),
|
|
246 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
|
|
247 ngx_conf_set_msec_slot,
|
|
248 NGX_HTTP_SRV_CONF_OFFSET,
|
|
249 offsetof(ngx_http_core_srv_conf_t, client_header_timeout),
|
|
250 NULL },
|
|
251
|
|
252 { ngx_string("client_header_buffer_size"),
|
|
253 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
|
|
254 ngx_conf_set_size_slot,
|
|
255 NGX_HTTP_SRV_CONF_OFFSET,
|
|
256 offsetof(ngx_http_core_srv_conf_t, client_header_buffer_size),
|
|
257 NULL },
|
|
258
|
|
259 { ngx_string("large_client_header_buffers"),
|
|
260 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE2,
|
|
261 ngx_conf_set_bufs_slot,
|
|
262 NGX_HTTP_SRV_CONF_OFFSET,
|
|
263 offsetof(ngx_http_core_srv_conf_t, large_client_header_buffers),
|
|
264 NULL },
|
|
265
|
158
|
266 { ngx_string("optimize_server_names"),
|
|
267 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG,
|
|
268 ngx_conf_set_flag_slot,
|
378
|
269 NGX_HTTP_LOC_CONF_OFFSET,
|
|
270 offsetof(ngx_http_core_loc_conf_t, server_name_in_redirect),
|
|
271 &ngx_conf_deprecated_optimize_server_names },
|
152
|
272
|
60
|
273 { ngx_string("ignore_invalid_headers"),
|
|
274 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG,
|
|
275 ngx_conf_set_flag_slot,
|
|
276 NGX_HTTP_SRV_CONF_OFFSET,
|
|
277 offsetof(ngx_http_core_srv_conf_t, ignore_invalid_headers),
|
|
278 NULL },
|
|
279
|
342
|
280 { ngx_string("merge_slashes"),
|
|
281 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG,
|
|
282 ngx_conf_set_flag_slot,
|
|
283 NGX_HTTP_SRV_CONF_OFFSET,
|
|
284 offsetof(ngx_http_core_srv_conf_t, merge_slashes),
|
|
285 NULL },
|
|
286
|
412
|
287 { ngx_string("underscores_in_headers"),
|
|
288 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG,
|
|
289 ngx_conf_set_flag_slot,
|
|
290 NGX_HTTP_SRV_CONF_OFFSET,
|
|
291 offsetof(ngx_http_core_srv_conf_t, underscores_in_headers),
|
|
292 NULL },
|
|
293
|
0
|
294 { ngx_string("location"),
|
|
295 NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_BLOCK|NGX_CONF_TAKE12,
|
34
|
296 ngx_http_core_location,
|
0
|
297 NGX_HTTP_SRV_CONF_OFFSET,
|
|
298 0,
|
|
299 NULL },
|
|
300
|
|
301 { ngx_string("listen"),
|
72
|
302 NGX_HTTP_SRV_CONF|NGX_CONF_1MORE,
|
34
|
303 ngx_http_core_listen,
|
0
|
304 NGX_HTTP_SRV_CONF_OFFSET,
|
|
305 0,
|
|
306 NULL },
|
|
307
|
|
308 { ngx_string("server_name"),
|
|
309 NGX_HTTP_SRV_CONF|NGX_CONF_1MORE,
|
34
|
310 ngx_http_core_server_name,
|
0
|
311 NGX_HTTP_SRV_CONF_OFFSET,
|
|
312 0,
|
|
313 NULL },
|
|
314
|
138
|
315 { ngx_string("types_hash_max_size"),
|
|
316 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
317 ngx_conf_set_num_slot,
|
|
318 NGX_HTTP_LOC_CONF_OFFSET,
|
|
319 offsetof(ngx_http_core_loc_conf_t, types_hash_max_size),
|
|
320 NULL },
|
|
321
|
|
322 { ngx_string("types_hash_bucket_size"),
|
|
323 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
324 ngx_conf_set_num_slot,
|
|
325 NGX_HTTP_LOC_CONF_OFFSET,
|
|
326 offsetof(ngx_http_core_loc_conf_t, types_hash_bucket_size),
|
|
327 NULL },
|
|
328
|
0
|
329 { ngx_string("types"),
|
|
330 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF
|
|
331 |NGX_CONF_BLOCK|NGX_CONF_NOARGS,
|
34
|
332 ngx_http_core_types,
|
0
|
333 NGX_HTTP_LOC_CONF_OFFSET,
|
|
334 0,
|
|
335 NULL },
|
|
336
|
|
337 { ngx_string("default_type"),
|
|
338 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
339 ngx_conf_set_str_slot,
|
|
340 NGX_HTTP_LOC_CONF_OFFSET,
|
|
341 offsetof(ngx_http_core_loc_conf_t, default_type),
|
|
342 NULL },
|
|
343
|
|
344 { ngx_string("root"),
|
58
|
345 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
|
|
346 |NGX_CONF_TAKE1,
|
34
|
347 ngx_http_core_root,
|
0
|
348 NGX_HTTP_LOC_CONF_OFFSET,
|
|
349 0,
|
|
350 NULL },
|
|
351
|
|
352 { ngx_string("alias"),
|
|
353 NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
34
|
354 ngx_http_core_root,
|
0
|
355 NGX_HTTP_LOC_CONF_OFFSET,
|
|
356 0,
|
|
357 NULL },
|
|
358
|
180
|
359 { ngx_string("limit_except"),
|
|
360 NGX_HTTP_LOC_CONF|NGX_CONF_BLOCK|NGX_CONF_1MORE,
|
|
361 ngx_http_core_limit_except,
|
|
362 NGX_HTTP_LOC_CONF_OFFSET,
|
|
363 0,
|
|
364 NULL },
|
|
365
|
0
|
366 { ngx_string("client_max_body_size"),
|
|
367 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
212
|
368 ngx_conf_set_off_slot,
|
0
|
369 NGX_HTTP_LOC_CONF_OFFSET,
|
|
370 offsetof(ngx_http_core_loc_conf_t, client_max_body_size),
|
|
371 NULL },
|
|
372
|
|
373 { ngx_string("client_body_buffer_size"),
|
|
374 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
375 ngx_conf_set_size_slot,
|
|
376 NGX_HTTP_LOC_CONF_OFFSET,
|
|
377 offsetof(ngx_http_core_loc_conf_t, client_body_buffer_size),
|
|
378 NULL },
|
|
379
|
|
380 { ngx_string("client_body_timeout"),
|
|
381 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
382 ngx_conf_set_msec_slot,
|
|
383 NGX_HTTP_LOC_CONF_OFFSET,
|
|
384 offsetof(ngx_http_core_loc_conf_t, client_body_timeout),
|
|
385 NULL },
|
|
386
|
28
|
387 { ngx_string("client_body_temp_path"),
|
|
388 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1234,
|
|
389 ngx_conf_set_path_slot,
|
|
390 NGX_HTTP_LOC_CONF_OFFSET,
|
|
391 offsetof(ngx_http_core_loc_conf_t, client_body_temp_path),
|
464
|
392 NULL },
|
28
|
393
|
182
|
394 { ngx_string("client_body_in_file_only"),
|
492
|
395 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
278
|
396 ngx_conf_set_enum_slot,
|
182
|
397 NGX_HTTP_LOC_CONF_OFFSET,
|
|
398 offsetof(ngx_http_core_loc_conf_t, client_body_in_file_only),
|
278
|
399 &ngx_http_core_request_body_in_file },
|
182
|
400
|
492
|
401 { ngx_string("client_body_in_single_buffer"),
|
|
402 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
403 ngx_conf_set_flag_slot,
|
|
404 NGX_HTTP_LOC_CONF_OFFSET,
|
|
405 offsetof(ngx_http_core_loc_conf_t, client_body_in_single_buffer),
|
|
406 NULL },
|
|
407
|
0
|
408 { ngx_string("sendfile"),
|
278
|
409 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
|
640
|
410 |NGX_CONF_FLAG,
|
0
|
411 ngx_conf_set_flag_slot,
|
|
412 NGX_HTTP_LOC_CONF_OFFSET,
|
|
413 offsetof(ngx_http_core_loc_conf_t, sendfile),
|
|
414 NULL },
|
|
415
|
300
|
416 { ngx_string("sendfile_max_chunk"),
|
|
417 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
418 ngx_conf_set_size_slot,
|
|
419 NGX_HTTP_LOC_CONF_OFFSET,
|
|
420 offsetof(ngx_http_core_loc_conf_t, sendfile_max_chunk),
|
|
421 NULL },
|
|
422
|
518
|
423 #if (NGX_HAVE_FILE_AIO)
|
|
424
|
|
425 { ngx_string("aio"),
|
520
|
426 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
427 ngx_conf_set_enum_slot,
|
518
|
428 NGX_HTTP_LOC_CONF_OFFSET,
|
|
429 offsetof(ngx_http_core_loc_conf_t, aio),
|
520
|
430 &ngx_http_core_aio },
|
518
|
431
|
|
432 #endif
|
|
433
|
532
|
434 { ngx_string("read_ahead"),
|
|
435 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
436 ngx_conf_set_size_slot,
|
|
437 NGX_HTTP_LOC_CONF_OFFSET,
|
|
438 offsetof(ngx_http_core_loc_conf_t, read_ahead),
|
|
439 NULL },
|
|
440
|
390
|
441 { ngx_string("directio"),
|
|
442 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
443 ngx_http_core_directio,
|
|
444 NGX_HTTP_LOC_CONF_OFFSET,
|
|
445 0,
|
|
446 NULL },
|
|
447
|
518
|
448 { ngx_string("directio_alignment"),
|
|
449 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
450 ngx_conf_set_off_slot,
|
|
451 NGX_HTTP_LOC_CONF_OFFSET,
|
|
452 offsetof(ngx_http_core_loc_conf_t, directio_alignment),
|
|
453 NULL },
|
|
454
|
0
|
455 { ngx_string("tcp_nopush"),
|
|
456 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
457 ngx_conf_set_flag_slot,
|
|
458 NGX_HTTP_LOC_CONF_OFFSET,
|
|
459 offsetof(ngx_http_core_loc_conf_t, tcp_nopush),
|
|
460 NULL },
|
|
461
|
2
|
462 { ngx_string("tcp_nodelay"),
|
|
463 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
464 ngx_conf_set_flag_slot,
|
|
465 NGX_HTTP_LOC_CONF_OFFSET,
|
|
466 offsetof(ngx_http_core_loc_conf_t, tcp_nodelay),
|
|
467 NULL },
|
|
468
|
0
|
469 { ngx_string("send_timeout"),
|
|
470 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
471 ngx_conf_set_msec_slot,
|
|
472 NGX_HTTP_LOC_CONF_OFFSET,
|
|
473 offsetof(ngx_http_core_loc_conf_t, send_timeout),
|
|
474 NULL },
|
|
475
|
|
476 { ngx_string("send_lowat"),
|
|
477 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
478 ngx_conf_set_size_slot,
|
|
479 NGX_HTTP_LOC_CONF_OFFSET,
|
|
480 offsetof(ngx_http_core_loc_conf_t, send_lowat),
|
34
|
481 &ngx_http_core_lowat_post },
|
0
|
482
|
|
483 { ngx_string("postpone_output"),
|
|
484 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
485 ngx_conf_set_size_slot,
|
|
486 NGX_HTTP_LOC_CONF_OFFSET,
|
|
487 offsetof(ngx_http_core_loc_conf_t, postpone_output),
|
|
488 NULL },
|
|
489
|
|
490 { ngx_string("limit_rate"),
|
34
|
491 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
|
|
492 |NGX_CONF_TAKE1,
|
0
|
493 ngx_conf_set_size_slot,
|
|
494 NGX_HTTP_LOC_CONF_OFFSET,
|
|
495 offsetof(ngx_http_core_loc_conf_t, limit_rate),
|
|
496 NULL },
|
|
497
|
496
|
498 { ngx_string("limit_rate_after"),
|
|
499 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
|
|
500 |NGX_CONF_TAKE1,
|
|
501 ngx_conf_set_size_slot,
|
|
502 NGX_HTTP_LOC_CONF_OFFSET,
|
|
503 offsetof(ngx_http_core_loc_conf_t, limit_rate_after),
|
|
504 NULL },
|
|
505
|
0
|
506 { ngx_string("keepalive_timeout"),
|
|
507 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE12,
|
34
|
508 ngx_http_core_keepalive,
|
0
|
509 NGX_HTTP_LOC_CONF_OFFSET,
|
|
510 0,
|
|
511 NULL },
|
|
512
|
496
|
513 { ngx_string("keepalive_requests"),
|
|
514 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
515 ngx_conf_set_num_slot,
|
|
516 NGX_HTTP_LOC_CONF_OFFSET,
|
|
517 offsetof(ngx_http_core_loc_conf_t, keepalive_requests),
|
|
518 NULL },
|
|
519
|
604
|
520 { ngx_string("keepalive_disable"),
|
648
|
521 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE12,
|
|
522 ngx_conf_set_bitmask_slot,
|
604
|
523 NGX_HTTP_LOC_CONF_OFFSET,
|
|
524 offsetof(ngx_http_core_loc_conf_t, keepalive_disable),
|
|
525 &ngx_http_core_keepalive_disable },
|
|
526
|
362
|
527 { ngx_string("satisfy"),
|
|
528 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
529 ngx_conf_set_enum_slot,
|
|
530 NGX_HTTP_LOC_CONF_OFFSET,
|
|
531 offsetof(ngx_http_core_loc_conf_t, satisfy),
|
|
532 &ngx_http_core_satisfy },
|
|
533
|
92
|
534 { ngx_string("satisfy_any"),
|
|
535 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
536 ngx_conf_set_flag_slot,
|
|
537 NGX_HTTP_LOC_CONF_OFFSET,
|
362
|
538 offsetof(ngx_http_core_loc_conf_t, satisfy),
|
|
539 &ngx_conf_deprecated_satisfy_any },
|
92
|
540
|
58
|
541 { ngx_string("internal"),
|
|
542 NGX_HTTP_LOC_CONF|NGX_CONF_NOARGS,
|
|
543 ngx_http_core_internal,
|
|
544 NGX_HTTP_LOC_CONF_OFFSET,
|
|
545 0,
|
|
546 NULL },
|
|
547
|
632
|
548 { ngx_string("lingering_close"),
|
|
549 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
550 ngx_conf_set_enum_slot,
|
|
551 NGX_HTTP_LOC_CONF_OFFSET,
|
|
552 offsetof(ngx_http_core_loc_conf_t, lingering_close),
|
|
553 &ngx_http_core_lingering_close },
|
|
554
|
0
|
555 { ngx_string("lingering_time"),
|
|
556 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
557 ngx_conf_set_msec_slot,
|
|
558 NGX_HTTP_LOC_CONF_OFFSET,
|
|
559 offsetof(ngx_http_core_loc_conf_t, lingering_time),
|
|
560 NULL },
|
|
561
|
|
562 { ngx_string("lingering_timeout"),
|
|
563 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
564 ngx_conf_set_msec_slot,
|
|
565 NGX_HTTP_LOC_CONF_OFFSET,
|
|
566 offsetof(ngx_http_core_loc_conf_t, lingering_timeout),
|
|
567 NULL },
|
|
568
|
|
569 { ngx_string("reset_timedout_connection"),
|
|
570 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
571 ngx_conf_set_flag_slot,
|
|
572 NGX_HTTP_LOC_CONF_OFFSET,
|
|
573 offsetof(ngx_http_core_loc_conf_t, reset_timedout_connection),
|
|
574 NULL },
|
|
575
|
362
|
576 { ngx_string("server_name_in_redirect"),
|
|
577 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
578 ngx_conf_set_flag_slot,
|
|
579 NGX_HTTP_LOC_CONF_OFFSET,
|
|
580 offsetof(ngx_http_core_loc_conf_t, server_name_in_redirect),
|
|
581 NULL },
|
|
582
|
70
|
583 { ngx_string("port_in_redirect"),
|
|
584 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
585 ngx_conf_set_flag_slot,
|
|
586 NGX_HTTP_LOC_CONF_OFFSET,
|
|
587 offsetof(ngx_http_core_loc_conf_t, port_in_redirect),
|
|
588 NULL },
|
|
589
|
0
|
590 { ngx_string("msie_padding"),
|
|
591 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
592 ngx_conf_set_flag_slot,
|
|
593 NGX_HTTP_LOC_CONF_OFFSET,
|
|
594 offsetof(ngx_http_core_loc_conf_t, msie_padding),
|
|
595 NULL },
|
|
596
|
228
|
597 { ngx_string("msie_refresh"),
|
|
598 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
599 ngx_conf_set_flag_slot,
|
|
600 NGX_HTTP_LOC_CONF_OFFSET,
|
|
601 offsetof(ngx_http_core_loc_conf_t, msie_refresh),
|
|
602 NULL },
|
|
603
|
76
|
604 { ngx_string("log_not_found"),
|
|
605 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
606 ngx_conf_set_flag_slot,
|
|
607 NGX_HTTP_LOC_CONF_OFFSET,
|
|
608 offsetof(ngx_http_core_loc_conf_t, log_not_found),
|
|
609 NULL },
|
|
610
|
412
|
611 { ngx_string("log_subrequest"),
|
|
612 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
613 ngx_conf_set_flag_slot,
|
|
614 NGX_HTTP_LOC_CONF_OFFSET,
|
|
615 offsetof(ngx_http_core_loc_conf_t, log_subrequest),
|
|
616 NULL },
|
|
617
|
228
|
618 { ngx_string("recursive_error_pages"),
|
|
619 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
620 ngx_conf_set_flag_slot,
|
|
621 NGX_HTTP_LOC_CONF_OFFSET,
|
|
622 offsetof(ngx_http_core_loc_conf_t, recursive_error_pages),
|
|
623 NULL },
|
|
624
|
342
|
625 { ngx_string("server_tokens"),
|
|
626 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
627 ngx_conf_set_flag_slot,
|
|
628 NGX_HTTP_LOC_CONF_OFFSET,
|
|
629 offsetof(ngx_http_core_loc_conf_t, server_tokens),
|
|
630 NULL },
|
|
631
|
424
|
632 { ngx_string("if_modified_since"),
|
|
633 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
634 ngx_conf_set_enum_slot,
|
|
635 NGX_HTTP_LOC_CONF_OFFSET,
|
|
636 offsetof(ngx_http_core_loc_conf_t, if_modified_since),
|
|
637 &ngx_http_core_if_modified_since },
|
|
638
|
636
|
639 { ngx_string("max_ranges"),
|
|
640 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
641 ngx_conf_set_num_slot,
|
|
642 NGX_HTTP_LOC_CONF_OFFSET,
|
|
643 offsetof(ngx_http_core_loc_conf_t, max_ranges),
|
|
644 NULL },
|
|
645
|
566
|
646 { ngx_string("chunked_transfer_encoding"),
|
640
|
647 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
566
|
648 ngx_conf_set_flag_slot,
|
|
649 NGX_HTTP_LOC_CONF_OFFSET,
|
|
650 offsetof(ngx_http_core_loc_conf_t, chunked_transfer_encoding),
|
|
651 NULL },
|
|
652
|
680
|
653 { ngx_string("etag"),
|
|
654 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
655 ngx_conf_set_flag_slot,
|
|
656 NGX_HTTP_LOC_CONF_OFFSET,
|
|
657 offsetof(ngx_http_core_loc_conf_t, etag),
|
|
658 NULL },
|
|
659
|
0
|
660 { ngx_string("error_page"),
|
58
|
661 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
|
|
662 |NGX_CONF_2MORE,
|
34
|
663 ngx_http_core_error_page,
|
0
|
664 NGX_HTTP_LOC_CONF_OFFSET,
|
|
665 0,
|
|
666 NULL },
|
|
667
|
430
|
668 { ngx_string("try_files"),
|
464
|
669 NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_2MORE,
|
430
|
670 ngx_http_core_try_files,
|
|
671 NGX_HTTP_LOC_CONF_OFFSET,
|
|
672 0,
|
|
673 NULL },
|
|
674
|
126
|
675 { ngx_string("post_action"),
|
|
676 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
|
|
677 |NGX_CONF_TAKE1,
|
|
678 ngx_conf_set_str_slot,
|
|
679 NGX_HTTP_LOC_CONF_OFFSET,
|
|
680 offsetof(ngx_http_core_loc_conf_t, post_action),
|
|
681 NULL },
|
|
682
|
0
|
683 { ngx_string("error_log"),
|
|
684 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
|
34
|
685 ngx_http_core_error_log,
|
0
|
686 NGX_HTTP_LOC_CONF_OFFSET,
|
|
687 0,
|
|
688 NULL },
|
|
689
|
|
690 { ngx_string("open_file_cache"),
|
332
|
691 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE12,
|
|
692 ngx_http_core_open_file_cache,
|
|
693 NGX_HTTP_LOC_CONF_OFFSET,
|
|
694 offsetof(ngx_http_core_loc_conf_t, open_file_cache),
|
|
695 NULL },
|
|
696
|
358
|
697 { ngx_string("open_file_cache_valid"),
|
|
698 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
699 ngx_conf_set_sec_slot,
|
|
700 NGX_HTTP_LOC_CONF_OFFSET,
|
|
701 offsetof(ngx_http_core_loc_conf_t, open_file_cache_valid),
|
|
702 NULL },
|
|
703
|
332
|
704 { ngx_string("open_file_cache_retest"),
|
|
705 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
706 ngx_conf_set_sec_slot,
|
0
|
707 NGX_HTTP_LOC_CONF_OFFSET,
|
358
|
708 offsetof(ngx_http_core_loc_conf_t, open_file_cache_valid),
|
|
709 &ngx_conf_deprecated_open_file_cache_retest },
|
|
710
|
|
711 { ngx_string("open_file_cache_min_uses"),
|
|
712 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
713 ngx_conf_set_num_slot,
|
|
714 NGX_HTTP_LOC_CONF_OFFSET,
|
|
715 offsetof(ngx_http_core_loc_conf_t, open_file_cache_min_uses),
|
0
|
716 NULL },
|
|
717
|
332
|
718 { ngx_string("open_file_cache_errors"),
|
|
719 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
720 ngx_conf_set_flag_slot,
|
|
721 NGX_HTTP_LOC_CONF_OFFSET,
|
|
722 offsetof(ngx_http_core_loc_conf_t, open_file_cache_errors),
|
|
723 NULL },
|
|
724
|
|
725 { ngx_string("open_file_cache_events"),
|
|
726 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
727 ngx_conf_set_flag_slot,
|
|
728 NGX_HTTP_LOC_CONF_OFFSET,
|
|
729 offsetof(ngx_http_core_loc_conf_t, open_file_cache_events),
|
|
730 NULL },
|
0
|
731
|
348
|
732 { ngx_string("resolver"),
|
646
|
733 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
|
348
|
734 ngx_http_core_resolver,
|
|
735 NGX_HTTP_LOC_CONF_OFFSET,
|
|
736 0,
|
|
737 NULL },
|
|
738
|
|
739 { ngx_string("resolver_timeout"),
|
|
740 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
741 ngx_conf_set_msec_slot,
|
|
742 NGX_HTTP_LOC_CONF_OFFSET,
|
|
743 offsetof(ngx_http_core_loc_conf_t, resolver_timeout),
|
|
744 NULL },
|
|
745
|
358
|
746 #if (NGX_HTTP_GZIP)
|
|
747
|
|
748 { ngx_string("gzip_vary"),
|
|
749 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
750 ngx_conf_set_flag_slot,
|
|
751 NGX_HTTP_LOC_CONF_OFFSET,
|
|
752 offsetof(ngx_http_core_loc_conf_t, gzip_vary),
|
|
753 NULL },
|
|
754
|
|
755 { ngx_string("gzip_http_version"),
|
|
756 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
|
|
757 ngx_conf_set_enum_slot,
|
|
758 NGX_HTTP_LOC_CONF_OFFSET,
|
|
759 offsetof(ngx_http_core_loc_conf_t, gzip_http_version),
|
|
760 &ngx_http_gzip_http_version },
|
|
761
|
|
762 { ngx_string("gzip_proxied"),
|
|
763 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
|
|
764 ngx_conf_set_bitmask_slot,
|
|
765 NGX_HTTP_LOC_CONF_OFFSET,
|
|
766 offsetof(ngx_http_core_loc_conf_t, gzip_proxied),
|
|
767 &ngx_http_gzip_proxied_mask },
|
|
768
|
|
769 { ngx_string("gzip_disable"),
|
|
770 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE,
|
|
771 ngx_http_gzip_disable,
|
|
772 NGX_HTTP_LOC_CONF_OFFSET,
|
|
773 0,
|
|
774 NULL },
|
|
775
|
|
776 #endif
|
|
777
|
662
|
778 #if (NGX_HAVE_OPENAT)
|
|
779
|
|
780 { ngx_string("disable_symlinks"),
|
664
|
781 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE12,
|
|
782 ngx_http_disable_symlinks,
|
662
|
783 NGX_HTTP_LOC_CONF_OFFSET,
|
664
|
784 0,
|
|
785 NULL },
|
662
|
786
|
|
787 #endif
|
|
788
|
0
|
789 ngx_null_command
|
|
790 };
|
|
791
|
|
792
|
216
|
793 static ngx_http_module_t ngx_http_core_module_ctx = {
|
58
|
794 ngx_http_core_preconfiguration, /* preconfiguration */
|
122
|
795 NULL, /* postconfiguration */
|
0
|
796
|
|
797 ngx_http_core_create_main_conf, /* create main configuration */
|
|
798 ngx_http_core_init_main_conf, /* init main configuration */
|
|
799
|
|
800 ngx_http_core_create_srv_conf, /* create server configuration */
|
|
801 ngx_http_core_merge_srv_conf, /* merge server configuration */
|
|
802
|
|
803 ngx_http_core_create_loc_conf, /* create location configuration */
|
|
804 ngx_http_core_merge_loc_conf /* merge location configuration */
|
|
805 };
|
|
806
|
|
807
|
|
808 ngx_module_t ngx_http_core_module = {
|
58
|
809 NGX_MODULE_V1,
|
0
|
810 &ngx_http_core_module_ctx, /* module context */
|
|
811 ngx_http_core_commands, /* module directives */
|
|
812 NGX_HTTP_MODULE, /* module type */
|
90
|
813 NULL, /* init master */
|
58
|
814 NULL, /* init module */
|
90
|
815 NULL, /* init process */
|
|
816 NULL, /* init thread */
|
|
817 NULL, /* exit thread */
|
|
818 NULL, /* exit process */
|
|
819 NULL, /* exit master */
|
|
820 NGX_MODULE_V1_PADDING
|
0
|
821 };
|
|
822
|
|
823
|
480
|
824 ngx_str_t ngx_http_core_get_method = { 3, (u_char *) "GET " };
|
364
|
825
|
|
826
|
36
|
827 void
|
|
828 ngx_http_handler(ngx_http_request_t *r)
|
0
|
829 {
|
230
|
830 ngx_http_core_main_conf_t *cmcf;
|
|
831
|
32
|
832 r->connection->log->action = NULL;
|
0
|
833
|
|
834 r->connection->unexpected_eof = 0;
|
|
835
|
224
|
836 if (!r->internal) {
|
92
|
837 switch (r->headers_in.connection_type) {
|
|
838 case 0:
|
612
|
839 r->keepalive = (r->http_version > NGX_HTTP_VERSION_10);
|
92
|
840 break;
|
|
841
|
|
842 case NGX_HTTP_CONNECTION_CLOSE:
|
|
843 r->keepalive = 0;
|
|
844 break;
|
|
845
|
|
846 case NGX_HTTP_CONNECTION_KEEP_ALIVE:
|
0
|
847 r->keepalive = 1;
|
92
|
848 break;
|
|
849 }
|
|
850
|
692
|
851 r->lingering_close = (r->headers_in.content_length_n > 0
|
|
852 || r->headers_in.chunked);
|
230
|
853 r->phase_handler = 0;
|
|
854
|
|
855 } else {
|
|
856 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
|
|
857 r->phase_handler = cmcf->phase_engine.server_rewrite_index;
|
|
858 }
|
|
859
|
236
|
860 r->valid_location = 1;
|
546
|
861 #if (NGX_HTTP_GZIP)
|
|
862 r->gzip_tested = 0;
|
|
863 r->gzip_ok = 0;
|
|
864 r->gzip_vary = 0;
|
|
865 #endif
|
236
|
866
|
230
|
867 r->write_event_handler = ngx_http_core_run_phases;
|
34
|
868 ngx_http_core_run_phases(r);
|
0
|
869 }
|
|
870
|
|
871
|
230
|
872 void
|
36
|
873 ngx_http_core_run_phases(ngx_http_request_t *r)
|
0
|
874 {
|
|
875 ngx_int_t rc;
|
230
|
876 ngx_http_phase_handler_t *ph;
|
0
|
877 ngx_http_core_main_conf_t *cmcf;
|
|
878
|
|
879 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
|
|
880
|
230
|
881 ph = cmcf->phase_engine.handlers;
|
|
882
|
|
883 while (ph[r->phase_handler].checker) {
|
|
884
|
|
885 rc = ph[r->phase_handler].checker(r, &ph[r->phase_handler]);
|
|
886
|
|
887 if (rc == NGX_OK) {
|
92
|
888 return;
|
0
|
889 }
|
|
890 }
|
|
891 }
|
|
892
|
|
893
|
36
|
894 ngx_int_t
|
230
|
895 ngx_http_core_generic_phase(ngx_http_request_t *r, ngx_http_phase_handler_t *ph)
|
|
896 {
|
|
897 ngx_int_t rc;
|
|
898
|
|
899 /*
|
|
900 * generic phase checker,
|
580
|
901 * used by the post read and pre-access phases
|
230
|
902 */
|
|
903
|
|
904 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
905 "generic phase: %ui", r->phase_handler);
|
|
906
|
|
907 rc = ph->handler(r);
|
|
908
|
|
909 if (rc == NGX_OK) {
|
|
910 r->phase_handler = ph->next;
|
|
911 return NGX_AGAIN;
|
|
912 }
|
|
913
|
|
914 if (rc == NGX_DECLINED) {
|
|
915 r->phase_handler++;
|
|
916 return NGX_AGAIN;
|
|
917 }
|
|
918
|
|
919 if (rc == NGX_AGAIN || rc == NGX_DONE) {
|
|
920 return NGX_OK;
|
|
921 }
|
|
922
|
|
923 /* rc == NGX_ERROR || rc == NGX_HTTP_... */
|
|
924
|
|
925 ngx_http_finalize_request(r, rc);
|
|
926
|
|
927 return NGX_OK;
|
|
928 }
|
|
929
|
|
930
|
|
931 ngx_int_t
|
580
|
932 ngx_http_core_rewrite_phase(ngx_http_request_t *r, ngx_http_phase_handler_t *ph)
|
|
933 {
|
|
934 ngx_int_t rc;
|
|
935
|
|
936 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
937 "rewrite phase: %ui", r->phase_handler);
|
|
938
|
|
939 rc = ph->handler(r);
|
|
940
|
|
941 if (rc == NGX_DECLINED) {
|
|
942 r->phase_handler++;
|
|
943 return NGX_AGAIN;
|
|
944 }
|
|
945
|
604
|
946 if (rc == NGX_DONE) {
|
|
947 return NGX_OK;
|
|
948 }
|
|
949
|
606
|
950 /* NGX_OK, NGX_AGAIN, NGX_ERROR, NGX_HTTP_... */
|
580
|
951
|
|
952 ngx_http_finalize_request(r, rc);
|
|
953
|
|
954 return NGX_OK;
|
|
955 }
|
|
956
|
|
957
|
|
958 ngx_int_t
|
230
|
959 ngx_http_core_find_config_phase(ngx_http_request_t *r,
|
|
960 ngx_http_phase_handler_t *ph)
|
0
|
961 {
|
328
|
962 u_char *p;
|
|
963 size_t len;
|
438
|
964 ngx_int_t rc;
|
0
|
965 ngx_http_core_loc_conf_t *clcf;
|
|
966
|
38
|
967 r->content_handler = NULL;
|
|
968 r->uri_changed = 0;
|
|
969
|
378
|
970 rc = ngx_http_core_find_location(r);
|
0
|
971
|
398
|
972 if (rc == NGX_ERROR) {
|
230
|
973 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
|
974 return NGX_OK;
|
0
|
975 }
|
|
976
|
|
977 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
|
978
|
58
|
979 if (!r->internal && clcf->internal) {
|
230
|
980 ngx_http_finalize_request(r, NGX_HTTP_NOT_FOUND);
|
|
981 return NGX_OK;
|
58
|
982 }
|
|
983
|
104
|
984 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
985 "using configuration \"%s%V\"",
|
|
986 (clcf->noname ? "*" : (clcf->exact_match ? "=" : "")),
|
|
987 &clcf->name);
|
|
988
|
84
|
989 ngx_http_update_location_config(r);
|
0
|
990
|
|
991 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
212
|
992 "http cl:%O max:%O",
|
10
|
993 r->headers_in.content_length_n, clcf->client_max_body_size);
|
0
|
994
|
|
995 if (r->headers_in.content_length_n != -1
|
222
|
996 && !r->discard_body
|
0
|
997 && clcf->client_max_body_size
|
212
|
998 && clcf->client_max_body_size < r->headers_in.content_length_n)
|
0
|
999 {
|
|
1000 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
342
|
1001 "client intended to send too large body: %O bytes",
|
0
|
1002 r->headers_in.content_length_n);
|
|
1003
|
524
|
1004 (void) ngx_http_discard_request_body(r);
|
230
|
1005 ngx_http_finalize_request(r, NGX_HTTP_REQUEST_ENTITY_TOO_LARGE);
|
|
1006 return NGX_OK;
|
0
|
1007 }
|
|
1008
|
378
|
1009 if (rc == NGX_DONE) {
|
644
|
1010 ngx_http_clear_location(r);
|
|
1011
|
0
|
1012 r->headers_out.location = ngx_list_push(&r->headers_out.headers);
|
|
1013 if (r->headers_out.location == NULL) {
|
230
|
1014 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
|
1015 return NGX_OK;
|
0
|
1016 }
|
|
1017
|
58
|
1018 /*
|
|
1019 * we do not need to set the r->headers_out.location->hash and
|
|
1020 * r->headers_out.location->key fields
|
|
1021 */
|
|
1022
|
328
|
1023 if (r->args.len == 0) {
|
|
1024 r->headers_out.location->value = clcf->name;
|
|
1025
|
|
1026 } else {
|
|
1027 len = clcf->name.len + 1 + r->args.len;
|
382
|
1028 p = ngx_pnalloc(r->pool, len);
|
328
|
1029
|
|
1030 if (p == NULL) {
|
|
1031 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
|
1032 return NGX_OK;
|
|
1033 }
|
|
1034
|
|
1035 r->headers_out.location->value.len = len;
|
|
1036 r->headers_out.location->value.data = p;
|
|
1037
|
|
1038 p = ngx_cpymem(p, clcf->name.data, clcf->name.len);
|
|
1039 *p++ = '?';
|
|
1040 ngx_memcpy(p, r->args.data, r->args.len);
|
|
1041 }
|
0
|
1042
|
230
|
1043 ngx_http_finalize_request(r, NGX_HTTP_MOVED_PERMANENTLY);
|
|
1044 return NGX_OK;
|
|
1045 }
|
|
1046
|
|
1047 r->phase_handler++;
|
|
1048 return NGX_AGAIN;
|
|
1049 }
|
|
1050
|
|
1051
|
|
1052 ngx_int_t
|
|
1053 ngx_http_core_post_rewrite_phase(ngx_http_request_t *r,
|
|
1054 ngx_http_phase_handler_t *ph)
|
|
1055 {
|
380
|
1056 ngx_http_core_srv_conf_t *cscf;
|
|
1057
|
230
|
1058 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
1059 "post rewrite phase: %ui", r->phase_handler);
|
|
1060
|
|
1061 if (!r->uri_changed) {
|
|
1062 r->phase_handler++;
|
|
1063 return NGX_AGAIN;
|
|
1064 }
|
|
1065
|
|
1066 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
1067 "uri changes: %d", r->uri_changes);
|
|
1068
|
|
1069 /*
|
|
1070 * gcc before 3.3 compiles the broken code for
|
|
1071 * if (r->uri_changes-- == 0)
|
|
1072 * if the r->uri_changes is defined as
|
|
1073 * unsigned uri_changes:4
|
|
1074 */
|
|
1075
|
|
1076 r->uri_changes--;
|
|
1077
|
|
1078 if (r->uri_changes == 0) {
|
|
1079 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
|
1080 "rewrite or internal redirection cycle "
|
|
1081 "while processing \"%V\"", &r->uri);
|
|
1082
|
|
1083 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
|
1084 return NGX_OK;
|
|
1085 }
|
|
1086
|
|
1087 r->phase_handler = ph->next;
|
|
1088
|
380
|
1089 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
|
|
1090 r->loc_conf = cscf->ctx->loc_conf;
|
|
1091
|
230
|
1092 return NGX_AGAIN;
|
|
1093 }
|
|
1094
|
|
1095
|
|
1096 ngx_int_t
|
|
1097 ngx_http_core_access_phase(ngx_http_request_t *r, ngx_http_phase_handler_t *ph)
|
|
1098 {
|
|
1099 ngx_int_t rc;
|
|
1100 ngx_http_core_loc_conf_t *clcf;
|
|
1101
|
|
1102 if (r != r->main) {
|
|
1103 r->phase_handler = ph->next;
|
|
1104 return NGX_AGAIN;
|
|
1105 }
|
|
1106
|
|
1107 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
1108 "access phase: %ui", r->phase_handler);
|
|
1109
|
|
1110 rc = ph->handler(r);
|
|
1111
|
|
1112 if (rc == NGX_DECLINED) {
|
|
1113 r->phase_handler++;
|
|
1114 return NGX_AGAIN;
|
|
1115 }
|
|
1116
|
|
1117 if (rc == NGX_AGAIN || rc == NGX_DONE) {
|
|
1118 return NGX_OK;
|
0
|
1119 }
|
|
1120
|
230
|
1121 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
|
1122
|
362
|
1123 if (clcf->satisfy == NGX_HTTP_SATISFY_ALL) {
|
230
|
1124
|
|
1125 if (rc == NGX_OK) {
|
|
1126 r->phase_handler++;
|
|
1127 return NGX_AGAIN;
|
|
1128 }
|
|
1129
|
|
1130 } else {
|
|
1131 if (rc == NGX_OK) {
|
|
1132 r->access_code = 0;
|
|
1133
|
|
1134 if (r->headers_out.www_authenticate) {
|
|
1135 r->headers_out.www_authenticate->hash = 0;
|
|
1136 }
|
|
1137
|
|
1138 r->phase_handler = ph->next;
|
|
1139 return NGX_AGAIN;
|
|
1140 }
|
|
1141
|
|
1142 if (rc == NGX_HTTP_FORBIDDEN || rc == NGX_HTTP_UNAUTHORIZED) {
|
|
1143 r->access_code = rc;
|
|
1144
|
|
1145 r->phase_handler++;
|
|
1146 return NGX_AGAIN;
|
|
1147 }
|
|
1148 }
|
|
1149
|
|
1150 /* rc == NGX_ERROR || rc == NGX_HTTP_... */
|
|
1151
|
|
1152 ngx_http_finalize_request(r, rc);
|
|
1153 return NGX_OK;
|
|
1154 }
|
|
1155
|
|
1156
|
|
1157 ngx_int_t
|
|
1158 ngx_http_core_post_access_phase(ngx_http_request_t *r,
|
|
1159 ngx_http_phase_handler_t *ph)
|
|
1160 {
|
620
|
1161 ngx_int_t access_code;
|
|
1162
|
230
|
1163 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
1164 "post access phase: %ui", r->phase_handler);
|
|
1165
|
620
|
1166 access_code = r->access_code;
|
|
1167
|
|
1168 if (access_code) {
|
|
1169 if (access_code == NGX_HTTP_FORBIDDEN) {
|
230
|
1170 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
|
1171 "access forbidden by rule");
|
|
1172 }
|
|
1173
|
620
|
1174 r->access_code = 0;
|
|
1175 ngx_http_finalize_request(r, access_code);
|
230
|
1176 return NGX_OK;
|
|
1177 }
|
|
1178
|
|
1179 r->phase_handler++;
|
|
1180 return NGX_AGAIN;
|
|
1181 }
|
|
1182
|
|
1183
|
|
1184 ngx_int_t
|
430
|
1185 ngx_http_core_try_files_phase(ngx_http_request_t *r,
|
|
1186 ngx_http_phase_handler_t *ph)
|
|
1187 {
|
442
|
1188 size_t len, root, alias, reserve, allocated;
|
430
|
1189 u_char *p, *name;
|
464
|
1190 ngx_str_t path, args;
|
440
|
1191 ngx_uint_t test_dir;
|
430
|
1192 ngx_http_try_file_t *tf;
|
|
1193 ngx_open_file_info_t of;
|
|
1194 ngx_http_script_code_pt code;
|
|
1195 ngx_http_script_engine_t e;
|
|
1196 ngx_http_core_loc_conf_t *clcf;
|
|
1197 ngx_http_script_len_code_pt lcode;
|
|
1198
|
|
1199 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
1200 "try files phase: %ui", r->phase_handler);
|
|
1201
|
|
1202 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
|
1203
|
|
1204 if (clcf->try_files == NULL) {
|
|
1205 r->phase_handler++;
|
|
1206 return NGX_AGAIN;
|
|
1207 }
|
|
1208
|
|
1209 allocated = 0;
|
|
1210 root = 0;
|
|
1211 name = NULL;
|
442
|
1212 /* suppress MSVC warning */
|
430
|
1213 path.data = NULL;
|
|
1214
|
|
1215 tf = clcf->try_files;
|
|
1216
|
574
|
1217 alias = clcf->alias;
|
430
|
1218
|
|
1219 for ( ;; ) {
|
|
1220
|
|
1221 if (tf->lengths) {
|
|
1222 ngx_memzero(&e, sizeof(ngx_http_script_engine_t));
|
|
1223
|
|
1224 e.ip = tf->lengths->elts;
|
|
1225 e.request = r;
|
|
1226
|
|
1227 /* 1 is for terminating '\0' as in static names */
|
|
1228 len = 1;
|
|
1229
|
|
1230 while (*(uintptr_t *) e.ip) {
|
|
1231 lcode = *(ngx_http_script_len_code_pt *) e.ip;
|
|
1232 len += lcode(&e);
|
|
1233 }
|
|
1234
|
|
1235 } else {
|
|
1236 len = tf->name.len;
|
|
1237 }
|
|
1238
|
670
|
1239 if (!alias) {
|
|
1240 reserve = len > r->uri.len ? len - r->uri.len : 0;
|
|
1241
|
|
1242 #if (NGX_PCRE)
|
|
1243 } else if (clcf->regex) {
|
|
1244 reserve = len;
|
|
1245 #endif
|
|
1246
|
|
1247 } else {
|
|
1248 reserve = len > r->uri.len - alias ? len - (r->uri.len - alias) : 0;
|
|
1249 }
|
430
|
1250
|
672
|
1251 if (reserve > allocated || !allocated) {
|
430
|
1252
|
670
|
1253 /* 16 bytes are preallocation */
|
|
1254 allocated = reserve + 16;
|
|
1255
|
|
1256 if (ngx_http_map_uri_to_path(r, &path, &root, allocated) == NULL) {
|
430
|
1257 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
|
1258 return NGX_OK;
|
|
1259 }
|
|
1260
|
|
1261 name = path.data + root;
|
|
1262 }
|
|
1263
|
|
1264 if (tf->values == NULL) {
|
|
1265
|
|
1266 /* tf->name.len includes the terminating '\0' */
|
|
1267
|
|
1268 ngx_memcpy(name, tf->name.data, tf->name.len);
|
|
1269
|
|
1270 path.len = (name + tf->name.len - 1) - path.data;
|
|
1271
|
|
1272 } else {
|
|
1273 e.ip = tf->values->elts;
|
|
1274 e.pos = name;
|
434
|
1275 e.flushed = 1;
|
430
|
1276
|
|
1277 while (*(uintptr_t *) e.ip) {
|
|
1278 code = *(ngx_http_script_code_pt *) e.ip;
|
|
1279 code((ngx_http_script_engine_t *) &e);
|
|
1280 }
|
|
1281
|
|
1282 path.len = e.pos - path.data;
|
|
1283
|
460
|
1284 *e.pos = '\0';
|
430
|
1285
|
|
1286 if (alias && ngx_strncmp(name, clcf->name.data, alias) == 0) {
|
620
|
1287 ngx_memmove(name, name + alias, len - alias);
|
430
|
1288 path.len -= alias;
|
|
1289 }
|
|
1290 }
|
|
1291
|
440
|
1292 test_dir = tf->test_dir;
|
|
1293
|
430
|
1294 tf++;
|
|
1295
|
574
|
1296 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
640
|
1297 "trying to use %s: \"%s\" \"%s\"",
|
574
|
1298 test_dir ? "dir" : "file", name, path.data);
|
430
|
1299
|
|
1300 if (tf->lengths == NULL && tf->name.len == 0) {
|
|
1301
|
478
|
1302 if (tf->code) {
|
|
1303 ngx_http_finalize_request(r, tf->code);
|
|
1304 return NGX_OK;
|
|
1305 }
|
|
1306
|
430
|
1307 path.len -= root;
|
|
1308 path.data += root;
|
|
1309
|
|
1310 if (path.data[0] == '@') {
|
|
1311 (void) ngx_http_named_location(r, &path);
|
|
1312
|
|
1313 } else {
|
464
|
1314 ngx_http_split_args(r, &path, &args);
|
|
1315
|
|
1316 (void) ngx_http_internal_redirect(r, &path, &args);
|
430
|
1317 }
|
|
1318
|
520
|
1319 ngx_http_finalize_request(r, NGX_DONE);
|
430
|
1320 return NGX_OK;
|
|
1321 }
|
|
1322
|
|
1323 ngx_memzero(&of, sizeof(ngx_open_file_info_t));
|
|
1324
|
654
|
1325 of.read_ahead = clcf->read_ahead;
|
430
|
1326 of.directio = clcf->directio;
|
|
1327 of.valid = clcf->open_file_cache_valid;
|
|
1328 of.min_uses = clcf->open_file_cache_min_uses;
|
482
|
1329 of.test_only = 1;
|
430
|
1330 of.errors = clcf->open_file_cache_errors;
|
|
1331 of.events = clcf->open_file_cache_events;
|
664
|
1332
|
|
1333 if (ngx_http_set_disable_symlinks(r, clcf, &path, &of) != NGX_OK) {
|
|
1334 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
|
1335 return NGX_OK;
|
|
1336 }
|
430
|
1337
|
|
1338 if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
|
|
1339 != NGX_OK)
|
|
1340 {
|
530
|
1341 if (of.err != NGX_ENOENT
|
|
1342 && of.err != NGX_ENOTDIR
|
|
1343 && of.err != NGX_ENAMETOOLONG)
|
|
1344 {
|
430
|
1345 ngx_log_error(NGX_LOG_CRIT, r->connection->log, of.err,
|
482
|
1346 "%s \"%s\" failed", of.failed, path.data);
|
430
|
1347 }
|
|
1348
|
|
1349 continue;
|
|
1350 }
|
|
1351
|
440
|
1352 if (of.is_dir && !test_dir) {
|
438
|
1353 continue;
|
|
1354 }
|
|
1355
|
430
|
1356 path.len -= root;
|
|
1357 path.data += root;
|
|
1358
|
|
1359 if (!alias) {
|
|
1360 r->uri = path;
|
|
1361
|
574
|
1362 #if (NGX_PCRE)
|
|
1363 } else if (clcf->regex) {
|
|
1364 if (!test_dir) {
|
|
1365 r->uri = path;
|
|
1366 r->add_uri_to_alias = 1;
|
|
1367 }
|
|
1368 #endif
|
430
|
1369 } else {
|
|
1370 r->uri.len = alias + path.len;
|
|
1371 r->uri.data = ngx_pnalloc(r->pool, r->uri.len);
|
|
1372 if (r->uri.data == NULL) {
|
|
1373 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
|
1374 return NGX_OK;
|
|
1375 }
|
|
1376
|
|
1377 p = ngx_copy(r->uri.data, clcf->name.data, alias);
|
|
1378 ngx_memcpy(p, name, path.len);
|
|
1379 }
|
|
1380
|
508
|
1381 ngx_http_set_exten(r);
|
446
|
1382
|
430
|
1383 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
1384 "try file uri: \"%V\"", &r->uri);
|
|
1385
|
|
1386 r->phase_handler++;
|
|
1387 return NGX_AGAIN;
|
|
1388 }
|
|
1389
|
|
1390 /* not reached */
|
|
1391 }
|
|
1392
|
|
1393
|
|
1394 ngx_int_t
|
230
|
1395 ngx_http_core_content_phase(ngx_http_request_t *r,
|
|
1396 ngx_http_phase_handler_t *ph)
|
|
1397 {
|
248
|
1398 size_t root;
|
230
|
1399 ngx_int_t rc;
|
|
1400 ngx_str_t path;
|
|
1401
|
|
1402 if (r->content_handler) {
|
|
1403 r->write_event_handler = ngx_http_request_empty_handler;
|
|
1404 ngx_http_finalize_request(r, r->content_handler(r));
|
|
1405 return NGX_OK;
|
|
1406 }
|
|
1407
|
|
1408 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
1409 "content phase: %ui", r->phase_handler);
|
|
1410
|
|
1411 rc = ph->handler(r);
|
|
1412
|
|
1413 if (rc != NGX_DECLINED) {
|
|
1414 ngx_http_finalize_request(r, rc);
|
|
1415 return NGX_OK;
|
|
1416 }
|
|
1417
|
|
1418 /* rc == NGX_DECLINED */
|
|
1419
|
|
1420 ph++;
|
|
1421
|
|
1422 if (ph->checker) {
|
|
1423 r->phase_handler++;
|
|
1424 return NGX_AGAIN;
|
|
1425 }
|
|
1426
|
|
1427 /* no content handler was found */
|
|
1428
|
572
|
1429 if (r->uri.data[r->uri.len - 1] == '/') {
|
230
|
1430
|
248
|
1431 if (ngx_http_map_uri_to_path(r, &path, &root, 0) != NULL) {
|
230
|
1432 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
340
|
1433 "directory index of \"%s\" is forbidden", path.data);
|
230
|
1434 }
|
|
1435
|
|
1436 ngx_http_finalize_request(r, NGX_HTTP_FORBIDDEN);
|
|
1437 return NGX_OK;
|
|
1438 }
|
|
1439
|
|
1440 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "no handler found");
|
|
1441
|
|
1442 ngx_http_finalize_request(r, NGX_HTTP_NOT_FOUND);
|
84
|
1443 return NGX_OK;
|
|
1444 }
|
|
1445
|
|
1446
|
|
1447 void
|
|
1448 ngx_http_update_location_config(ngx_http_request_t *r)
|
|
1449 {
|
|
1450 ngx_http_core_loc_conf_t *clcf;
|
|
1451
|
|
1452 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
|
1453
|
180
|
1454 if (r->method & clcf->limit_except) {
|
|
1455 r->loc_conf = clcf->limit_except_loc_conf;
|
|
1456 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
|
1457 }
|
|
1458
|
192
|
1459 if (r == r->main) {
|
484
|
1460 r->connection->log->file = clcf->error_log->file;
|
294
|
1461
|
192
|
1462 if (!(r->connection->log->log_level & NGX_LOG_DEBUG_CONNECTION)) {
|
484
|
1463 r->connection->log->log_level = clcf->error_log->log_level;
|
192
|
1464 }
|
84
|
1465 }
|
|
1466
|
|
1467 if ((ngx_io.flags & NGX_IO_SENDFILE) && clcf->sendfile) {
|
|
1468 r->connection->sendfile = 1;
|
|
1469
|
|
1470 } else {
|
|
1471 r->connection->sendfile = 0;
|
|
1472 }
|
|
1473
|
182
|
1474 if (clcf->client_body_in_file_only) {
|
|
1475 r->request_body_in_file_only = 1;
|
|
1476 r->request_body_in_persistent_file = 1;
|
278
|
1477 r->request_body_in_clean_file =
|
|
1478 clcf->client_body_in_file_only == NGX_HTTP_REQUEST_BODY_FILE_CLEAN;
|
186
|
1479 r->request_body_file_log_level = NGX_LOG_NOTICE;
|
|
1480
|
|
1481 } else {
|
|
1482 r->request_body_file_log_level = NGX_LOG_WARN;
|
182
|
1483 }
|
|
1484
|
492
|
1485 r->request_body_in_single_buf = clcf->client_body_in_single_buffer;
|
|
1486
|
496
|
1487 if (r->keepalive) {
|
|
1488 if (clcf->keepalive_timeout == 0) {
|
|
1489 r->keepalive = 0;
|
|
1490
|
|
1491 } else if (r->connection->requests >= clcf->keepalive_requests) {
|
|
1492 r->keepalive = 0;
|
604
|
1493
|
|
1494 } else if (r->headers_in.msie6
|
|
1495 && r->method == NGX_HTTP_POST
|
|
1496 && (clcf->keepalive_disable
|
|
1497 & NGX_HTTP_KEEPALIVE_DISABLE_MSIE6))
|
|
1498 {
|
|
1499 /*
|
|
1500 * MSIE may wait for some time if an response for
|
|
1501 * a POST request was sent over a keepalive connection
|
|
1502 */
|
|
1503 r->keepalive = 0;
|
|
1504
|
|
1505 } else if (r->headers_in.safari
|
|
1506 && (clcf->keepalive_disable
|
|
1507 & NGX_HTTP_KEEPALIVE_DISABLE_SAFARI))
|
|
1508 {
|
|
1509 /*
|
|
1510 * Safari may send a POST request to a closed keepalive
|
|
1511 * connection and may stall for some time, see
|
|
1512 * https://bugs.webkit.org/show_bug.cgi?id=5760
|
|
1513 */
|
|
1514 r->keepalive = 0;
|
496
|
1515 }
|
84
|
1516 }
|
|
1517
|
|
1518 if (!clcf->tcp_nopush) {
|
|
1519 /* disable TCP_NOPUSH/TCP_CORK use */
|
|
1520 r->connection->tcp_nopush = NGX_TCP_NOPUSH_DISABLED;
|
|
1521 }
|
|
1522
|
162
|
1523 if (r->limit_rate == 0) {
|
|
1524 r->limit_rate = clcf->limit_rate;
|
|
1525 }
|
76
|
1526
|
0
|
1527 if (clcf->handler) {
|
|
1528 r->content_handler = clcf->handler;
|
|
1529 }
|
|
1530 }
|
|
1531
|
|
1532
|
398
|
1533 /*
|
|
1534 * NGX_OK - exact or regex match
|
|
1535 * NGX_DONE - auto redirect
|
|
1536 * NGX_AGAIN - inclusive match
|
|
1537 * NGX_ERROR - regex error
|
|
1538 * NGX_DECLINED - no match
|
|
1539 */
|
|
1540
|
36
|
1541 static ngx_int_t
|
378
|
1542 ngx_http_core_find_location(ngx_http_request_t *r)
|
0
|
1543 {
|
378
|
1544 ngx_int_t rc;
|
|
1545 ngx_http_core_loc_conf_t *pclcf;
|
398
|
1546 #if (NGX_PCRE)
|
546
|
1547 ngx_int_t n;
|
398
|
1548 ngx_uint_t noregex;
|
|
1549 ngx_http_core_loc_conf_t *clcf, **clcfp;
|
|
1550
|
|
1551 noregex = 0;
|
|
1552 #endif
|
378
|
1553
|
|
1554 pclcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
|
1555
|
|
1556 rc = ngx_http_core_find_static_location(r, pclcf->static_locations);
|
|
1557
|
|
1558 if (rc == NGX_AGAIN) {
|
398
|
1559
|
|
1560 #if (NGX_PCRE)
|
|
1561 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
|
1562
|
|
1563 noregex = clcf->noregex;
|
|
1564 #endif
|
|
1565
|
378
|
1566 /* look up nested locations */
|
398
|
1567
|
378
|
1568 rc = ngx_http_core_find_location(r);
|
|
1569 }
|
|
1570
|
|
1571 if (rc == NGX_OK || rc == NGX_DONE) {
|
|
1572 return rc;
|
|
1573 }
|
|
1574
|
|
1575 /* rc == NGX_DECLINED or rc == NGX_AGAIN in nested location */
|
|
1576
|
|
1577 #if (NGX_PCRE)
|
398
|
1578
|
|
1579 if (noregex == 0 && pclcf->regex_locations) {
|
378
|
1580
|
|
1581 for (clcfp = pclcf->regex_locations; *clcfp; clcfp++) {
|
|
1582
|
|
1583 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
1584 "test location: ~ \"%V\"", &(*clcfp)->name);
|
|
1585
|
546
|
1586 n = ngx_http_regex_exec(r, (*clcfp)->regex, &r->uri);
|
|
1587
|
|
1588 if (n == NGX_OK) {
|
|
1589 r->loc_conf = (*clcfp)->loc_conf;
|
|
1590
|
|
1591 /* look up nested locations */
|
|
1592
|
|
1593 rc = ngx_http_core_find_location(r);
|
|
1594
|
|
1595 return (rc == NGX_ERROR) ? rc : NGX_OK;
|
456
|
1596 }
|
|
1597
|
546
|
1598 if (n == NGX_DECLINED) {
|
378
|
1599 continue;
|
|
1600 }
|
|
1601
|
546
|
1602 return NGX_ERROR;
|
378
|
1603 }
|
|
1604 }
|
326
|
1605 #endif
|
0
|
1606
|
378
|
1607 return rc;
|
|
1608 }
|
|
1609
|
|
1610
|
|
1611 /*
|
|
1612 * NGX_OK - exact match
|
|
1613 * NGX_DONE - auto redirect
|
|
1614 * NGX_AGAIN - inclusive match
|
|
1615 * NGX_DECLINED - no match
|
|
1616 */
|
|
1617
|
|
1618 static ngx_int_t
|
|
1619 ngx_http_core_find_static_location(ngx_http_request_t *r,
|
|
1620 ngx_http_location_tree_node_t *node)
|
|
1621 {
|
|
1622 u_char *uri;
|
|
1623 size_t len, n;
|
|
1624 ngx_int_t rc, rv;
|
|
1625
|
|
1626 len = r->uri.len;
|
|
1627 uri = r->uri.data;
|
|
1628
|
|
1629 rv = NGX_DECLINED;
|
|
1630
|
|
1631 for ( ;; ) {
|
|
1632
|
|
1633 if (node == NULL) {
|
|
1634 return rv;
|
34
|
1635 }
|
|
1636
|
0
|
1637 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
378
|
1638 "test location: \"%*s\"", node->len, node->name);
|
|
1639
|
|
1640 n = (len <= (size_t) node->len) ? len : node->len;
|
|
1641
|
390
|
1642 rc = ngx_filename_cmp(uri, node->name, n);
|
378
|
1643
|
|
1644 if (rc != 0) {
|
|
1645 node = (rc < 0) ? node->left : node->right;
|
|
1646
|
0
|
1647 continue;
|
|
1648 }
|
|
1649
|
378
|
1650 if (len > (size_t) node->len) {
|
|
1651
|
|
1652 if (node->inclusive) {
|
|
1653
|
|
1654 r->loc_conf = node->inclusive->loc_conf;
|
|
1655 rv = NGX_AGAIN;
|
|
1656
|
|
1657 node = node->tree;
|
|
1658 uri += n;
|
|
1659 len -= n;
|
34
|
1660
|
|
1661 continue;
|
0
|
1662 }
|
|
1663
|
378
|
1664 /* exact only */
|
|
1665
|
|
1666 node = node->right;
|
|
1667
|
0
|
1668 continue;
|
|
1669 }
|
|
1670
|
378
|
1671 if (len == (size_t) node->len) {
|
|
1672
|
580
|
1673 if (node->exact) {
|
|
1674 r->loc_conf = node->exact->loc_conf;
|
|
1675 return NGX_OK;
|
|
1676
|
|
1677 } else {
|
|
1678 r->loc_conf = node->inclusive->loc_conf;
|
|
1679 return NGX_AGAIN;
|
|
1680 }
|
0
|
1681 }
|
|
1682
|
378
|
1683 /* len < node->len */
|
|
1684
|
|
1685 if (len + 1 == (size_t) node->len && node->auto_redirect) {
|
|
1686
|
|
1687 r->loc_conf = (node->exact) ? node->exact->loc_conf:
|
|
1688 node->inclusive->loc_conf;
|
|
1689 rv = NGX_DONE;
|
|
1690 }
|
|
1691
|
|
1692 node = node->left;
|
0
|
1693 }
|
|
1694 }
|
|
1695
|
|
1696
|
392
|
1697 void *
|
|
1698 ngx_http_test_content_type(ngx_http_request_t *r, ngx_hash_t *types_hash)
|
|
1699 {
|
494
|
1700 u_char c, *lowcase;
|
|
1701 size_t len;
|
|
1702 ngx_uint_t i, hash;
|
392
|
1703
|
554
|
1704 if (types_hash->size == 0) {
|
|
1705 return (void *) 4;
|
|
1706 }
|
|
1707
|
392
|
1708 if (r->headers_out.content_type.len == 0) {
|
|
1709 return NULL;
|
|
1710 }
|
|
1711
|
494
|
1712 len = r->headers_out.content_type_len;
|
|
1713
|
392
|
1714 if (r->headers_out.content_type_lowcase == NULL) {
|
|
1715
|
494
|
1716 lowcase = ngx_pnalloc(r->pool, len);
|
|
1717 if (lowcase == NULL) {
|
392
|
1718 return NULL;
|
|
1719 }
|
|
1720
|
494
|
1721 r->headers_out.content_type_lowcase = lowcase;
|
392
|
1722
|
|
1723 hash = 0;
|
|
1724
|
494
|
1725 for (i = 0; i < len; i++) {
|
392
|
1726 c = ngx_tolower(r->headers_out.content_type.data[i]);
|
|
1727 hash = ngx_hash(hash, c);
|
494
|
1728 lowcase[i] = c;
|
392
|
1729 }
|
|
1730
|
|
1731 r->headers_out.content_type_hash = hash;
|
|
1732 }
|
|
1733
|
494
|
1734 return ngx_hash_find(types_hash, r->headers_out.content_type_hash,
|
|
1735 r->headers_out.content_type_lowcase, len);
|
392
|
1736 }
|
|
1737
|
|
1738
|
36
|
1739 ngx_int_t
|
|
1740 ngx_http_set_content_type(ngx_http_request_t *r)
|
0
|
1741 {
|
392
|
1742 u_char c, *exten;
|
138
|
1743 ngx_str_t *type;
|
198
|
1744 ngx_uint_t i, hash;
|
0
|
1745 ngx_http_core_loc_conf_t *clcf;
|
|
1746
|
222
|
1747 if (r->headers_out.content_type.len) {
|
|
1748 return NGX_OK;
|
|
1749 }
|
|
1750
|
0
|
1751 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
|
1752
|
|
1753 if (r->exten.len) {
|
34
|
1754
|
198
|
1755 hash = 0;
|
|
1756
|
|
1757 for (i = 0; i < r->exten.len; i++) {
|
|
1758 c = r->exten.data[i];
|
|
1759
|
|
1760 if (c >= 'A' && c <= 'Z') {
|
|
1761
|
392
|
1762 exten = ngx_pnalloc(r->pool, r->exten.len);
|
|
1763 if (exten == NULL) {
|
454
|
1764 return NGX_ERROR;
|
34
|
1765 }
|
|
1766
|
392
|
1767 hash = ngx_hash_strlow(exten, r->exten.data, r->exten.len);
|
34
|
1768
|
|
1769 r->exten.data = exten;
|
198
|
1770
|
|
1771 break;
|
34
|
1772 }
|
|
1773
|
198
|
1774 hash = ngx_hash(hash, c);
|
34
|
1775 }
|
|
1776
|
198
|
1777 type = ngx_hash_find(&clcf->types_hash, hash,
|
138
|
1778 r->exten.data, r->exten.len);
|
|
1779
|
|
1780 if (type) {
|
206
|
1781 r->headers_out.content_type_len = type->len;
|
138
|
1782 r->headers_out.content_type = *type;
|
206
|
1783
|
138
|
1784 return NGX_OK;
|
0
|
1785 }
|
|
1786 }
|
|
1787
|
206
|
1788 r->headers_out.content_type_len = clcf->default_type.len;
|
138
|
1789 r->headers_out.content_type = clcf->default_type;
|
0
|
1790
|
|
1791 return NGX_OK;
|
|
1792 }
|
|
1793
|
|
1794
|
508
|
1795 void
|
36
|
1796 ngx_http_set_exten(ngx_http_request_t *r)
|
0
|
1797 {
|
|
1798 ngx_int_t i;
|
|
1799
|
570
|
1800 ngx_str_null(&r->exten);
|
0
|
1801
|
|
1802 for (i = r->uri.len - 1; i > 1; i--) {
|
|
1803 if (r->uri.data[i] == '.' && r->uri.data[i - 1] != '/') {
|
198
|
1804
|
0
|
1805 r->exten.len = r->uri.len - i - 1;
|
198
|
1806 r->exten.data = &r->uri.data[i + 1];
|
0
|
1807
|
508
|
1808 return;
|
0
|
1809
|
|
1810 } else if (r->uri.data[i] == '/') {
|
508
|
1811 return;
|
0
|
1812 }
|
|
1813 }
|
|
1814
|
508
|
1815 return;
|
0
|
1816 }
|
|
1817
|
|
1818
|
36
|
1819 ngx_int_t
|
680
|
1820 ngx_http_set_etag(ngx_http_request_t *r)
|
|
1821 {
|
|
1822 ngx_table_elt_t *etag;
|
|
1823 ngx_http_core_loc_conf_t *clcf;
|
684
|
1824
|
680
|
1825 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
684
|
1826
|
680
|
1827 if (!clcf->etag) {
|
|
1828 return NGX_OK;
|
|
1829 }
|
|
1830
|
|
1831 etag = ngx_list_push(&r->headers_out.headers);
|
|
1832 if (etag == NULL) {
|
|
1833 return NGX_ERROR;
|
|
1834 }
|
|
1835
|
|
1836 etag->hash = 1;
|
|
1837 ngx_str_set(&etag->key, "ETag");
|
|
1838
|
|
1839 etag->value.data = ngx_pnalloc(r->pool, NGX_OFF_T_LEN + NGX_TIME_T_LEN + 3);
|
|
1840 if (etag->value.data == NULL) {
|
|
1841 return NGX_ERROR;
|
|
1842 }
|
|
1843
|
|
1844 etag->value.len = ngx_sprintf(etag->value.data, "\"%xT-%xO\"",
|
|
1845 r->headers_out.last_modified_time,
|
|
1846 r->headers_out.content_length_n)
|
|
1847 - etag->value.data;
|
|
1848
|
|
1849 r->headers_out.etag = etag;
|
|
1850
|
|
1851 return NGX_OK;
|
|
1852 }
|
|
1853
|
|
1854
|
|
1855 ngx_int_t
|
580
|
1856 ngx_http_send_response(ngx_http_request_t *r, ngx_uint_t status,
|
|
1857 ngx_str_t *ct, ngx_http_complex_value_t *cv)
|
|
1858 {
|
|
1859 ngx_int_t rc;
|
|
1860 ngx_str_t val;
|
|
1861 ngx_buf_t *b;
|
|
1862 ngx_chain_t out;
|
|
1863
|
642
|
1864 if (ngx_http_discard_request_body(r) != NGX_OK) {
|
|
1865 return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
|
1866 }
|
|
1867
|
580
|
1868 r->headers_out.status = status;
|
|
1869
|
|
1870 if (ngx_http_complex_value(r, cv, &val) != NGX_OK) {
|
|
1871 return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
|
1872 }
|
|
1873
|
664
|
1874 if (status == NGX_HTTP_MOVED_PERMANENTLY
|
|
1875 || status == NGX_HTTP_MOVED_TEMPORARILY
|
|
1876 || status == NGX_HTTP_SEE_OTHER
|
|
1877 || status == NGX_HTTP_TEMPORARY_REDIRECT)
|
|
1878 {
|
644
|
1879 ngx_http_clear_location(r);
|
|
1880
|
580
|
1881 r->headers_out.location = ngx_list_push(&r->headers_out.headers);
|
|
1882 if (r->headers_out.location == NULL) {
|
|
1883 return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
|
1884 }
|
|
1885
|
|
1886 r->headers_out.location->hash = 1;
|
|
1887 ngx_str_set(&r->headers_out.location->key, "Location");
|
|
1888 r->headers_out.location->value = val;
|
|
1889
|
|
1890 return status;
|
|
1891 }
|
|
1892
|
|
1893 r->headers_out.content_length_n = val.len;
|
|
1894
|
|
1895 if (ct) {
|
|
1896 r->headers_out.content_type_len = ct->len;
|
|
1897 r->headers_out.content_type = *ct;
|
|
1898
|
|
1899 } else {
|
|
1900 if (ngx_http_set_content_type(r) != NGX_OK) {
|
|
1901 return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
|
1902 }
|
|
1903 }
|
|
1904
|
|
1905 if (r->method == NGX_HTTP_HEAD || (r != r->main && val.len == 0)) {
|
|
1906 return ngx_http_send_header(r);
|
|
1907 }
|
|
1908
|
|
1909 b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
|
|
1910 if (b == NULL) {
|
|
1911 return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
|
1912 }
|
|
1913
|
|
1914 b->pos = val.data;
|
|
1915 b->last = val.data + val.len;
|
|
1916 b->memory = val.len ? 1 : 0;
|
|
1917 b->last_buf = (r == r->main) ? 1 : 0;
|
|
1918 b->last_in_chain = 1;
|
|
1919
|
|
1920 out.buf = b;
|
|
1921 out.next = NULL;
|
|
1922
|
|
1923 rc = ngx_http_send_header(r);
|
|
1924
|
|
1925 if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) {
|
|
1926 return rc;
|
|
1927 }
|
|
1928
|
|
1929 return ngx_http_output_filter(r, &out);
|
|
1930 }
|
|
1931
|
|
1932
|
|
1933 ngx_int_t
|
106
|
1934 ngx_http_send_header(ngx_http_request_t *r)
|
|
1935 {
|
|
1936 if (r->err_status) {
|
|
1937 r->headers_out.status = r->err_status;
|
|
1938 r->headers_out.status_line.len = 0;
|
|
1939 }
|
|
1940
|
|
1941 return ngx_http_top_header_filter(r);
|
|
1942 }
|
|
1943
|
|
1944
|
|
1945 ngx_int_t
|
|
1946 ngx_http_output_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|
1947 {
|
488
|
1948 ngx_int_t rc;
|
|
1949 ngx_connection_t *c;
|
|
1950
|
|
1951 c = r->connection;
|
|
1952
|
|
1953 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
|
132
|
1954 "http output filter \"%V?%V\"", &r->uri, &r->args);
|
106
|
1955
|
|
1956 rc = ngx_http_top_body_filter(r, in);
|
|
1957
|
|
1958 if (rc == NGX_ERROR) {
|
|
1959 /* NGX_ERROR may be returned by any filter */
|
488
|
1960 c->error = 1;
|
106
|
1961 }
|
|
1962
|
|
1963 return rc;
|
|
1964 }
|
|
1965
|
|
1966
|
|
1967 u_char *
|
|
1968 ngx_http_map_uri_to_path(ngx_http_request_t *r, ngx_str_t *path,
|
248
|
1969 size_t *root_length, size_t reserved)
|
106
|
1970 {
|
172
|
1971 u_char *last;
|
|
1972 size_t alias;
|
|
1973 ngx_http_core_loc_conf_t *clcf;
|
106
|
1974
|
|
1975 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
|
1976
|
574
|
1977 alias = clcf->alias;
|
106
|
1978
|
152
|
1979 if (alias && !r->valid_location) {
|
|
1980 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
|
640
|
1981 "\"alias\" cannot be used in location \"%V\" "
|
152
|
1982 "where URI was rewritten", &clcf->name);
|
|
1983 return NULL;
|
|
1984 }
|
|
1985
|
144
|
1986 if (clcf->root_lengths == NULL) {
|
|
1987
|
248
|
1988 *root_length = clcf->root.len;
|
144
|
1989
|
460
|
1990 path->len = clcf->root.len + reserved + r->uri.len - alias + 1;
|
144
|
1991
|
382
|
1992 path->data = ngx_pnalloc(r->pool, path->len);
|
144
|
1993 if (path->data == NULL) {
|
|
1994 return NULL;
|
|
1995 }
|
|
1996
|
|
1997 last = ngx_copy(path->data, clcf->root.data, clcf->root.len);
|
172
|
1998
|
|
1999 } else {
|
468
|
2000
|
|
2001 #if (NGX_PCRE)
|
|
2002 ngx_uint_t captures;
|
|
2003
|
546
|
2004 captures = alias && clcf->regex;
|
574
|
2005
|
|
2006 reserved += captures ? r->add_uri_to_alias ? r->uri.len + 1 : 1
|
|
2007 : r->uri.len - alias + 1;
|
468
|
2008 #else
|
|
2009 reserved += r->uri.len - alias + 1;
|
|
2010 #endif
|
462
|
2011
|
|
2012 if (ngx_http_script_run(r, path, clcf->root_lengths->elts, reserved,
|
220
|
2013 clcf->root_values->elts)
|
216
|
2014 == NULL)
|
|
2015 {
|
|
2016 return NULL;
|
|
2017 }
|
|
2018
|
454
|
2019 if (ngx_conf_full_name((ngx_cycle_t *) ngx_cycle, path, 0) != NGX_OK) {
|
172
|
2020 return NULL;
|
|
2021 }
|
|
2022
|
248
|
2023 *root_length = path->len - reserved;
|
|
2024 last = path->data + *root_length;
|
456
|
2025
|
468
|
2026 #if (NGX_PCRE)
|
|
2027 if (captures) {
|
574
|
2028 if (!r->add_uri_to_alias) {
|
|
2029 *last = '\0';
|
|
2030 return last;
|
|
2031 }
|
|
2032
|
|
2033 alias = 0;
|
456
|
2034 }
|
468
|
2035 #endif
|
144
|
2036 }
|
|
2037
|
172
|
2038 last = ngx_cpystrn(last, r->uri.data + alias, r->uri.len - alias + 1);
|
106
|
2039
|
|
2040 return last;
|
|
2041 }
|
|
2042
|
|
2043
|
|
2044 ngx_int_t
|
88
|
2045 ngx_http_auth_basic_user(ngx_http_request_t *r)
|
|
2046 {
|
|
2047 ngx_str_t auth, encoded;
|
|
2048 ngx_uint_t len;
|
|
2049
|
|
2050 if (r->headers_in.user.len == 0 && r->headers_in.user.data != NULL) {
|
|
2051 return NGX_DECLINED;
|
|
2052 }
|
|
2053
|
|
2054 if (r->headers_in.authorization == NULL) {
|
|
2055 r->headers_in.user.data = (u_char *) "";
|
|
2056 return NGX_DECLINED;
|
|
2057 }
|
|
2058
|
|
2059 encoded = r->headers_in.authorization->value;
|
|
2060
|
|
2061 if (encoded.len < sizeof("Basic ") - 1
|
286
|
2062 || ngx_strncasecmp(encoded.data, (u_char *) "Basic ",
|
|
2063 sizeof("Basic ") - 1)
|
|
2064 != 0)
|
88
|
2065 {
|
|
2066 r->headers_in.user.data = (u_char *) "";
|
|
2067 return NGX_DECLINED;
|
|
2068 }
|
|
2069
|
|
2070 encoded.len -= sizeof("Basic ") - 1;
|
|
2071 encoded.data += sizeof("Basic ") - 1;
|
|
2072
|
|
2073 while (encoded.len && encoded.data[0] == ' ') {
|
|
2074 encoded.len--;
|
|
2075 encoded.data++;
|
|
2076 }
|
|
2077
|
|
2078 if (encoded.len == 0) {
|
|
2079 r->headers_in.user.data = (u_char *) "";
|
|
2080 return NGX_DECLINED;
|
|
2081 }
|
126
|
2082
|
88
|
2083 auth.len = ngx_base64_decoded_length(encoded.len);
|
382
|
2084 auth.data = ngx_pnalloc(r->pool, auth.len + 1);
|
88
|
2085 if (auth.data == NULL) {
|
|
2086 return NGX_ERROR;
|
|
2087 }
|
|
2088
|
|
2089 if (ngx_decode_base64(&auth, &encoded) != NGX_OK) {
|
|
2090 r->headers_in.user.data = (u_char *) "";
|
|
2091 return NGX_DECLINED;
|
|
2092 }
|
126
|
2093
|
88
|
2094 auth.data[auth.len] = '\0';
|
126
|
2095
|
|
2096 for (len = 0; len < auth.len; len++) {
|
88
|
2097 if (auth.data[len] == ':') {
|
|
2098 break;
|
|
2099 }
|
|
2100 }
|
126
|
2101
|
122
|
2102 if (len == 0 || len == auth.len) {
|
88
|
2103 r->headers_in.user.data = (u_char *) "";
|
|
2104 return NGX_DECLINED;
|
|
2105 }
|
|
2106
|
|
2107 r->headers_in.user.len = len;
|
|
2108 r->headers_in.user.data = auth.data;
|
|
2109 r->headers_in.passwd.len = auth.len - len - 1;
|
|
2110 r->headers_in.passwd.data = &auth.data[len + 1];
|
|
2111
|
|
2112 return NGX_OK;
|
|
2113 }
|
|
2114
|
|
2115
|
358
|
2116 #if (NGX_HTTP_GZIP)
|
|
2117
|
|
2118 ngx_int_t
|
|
2119 ngx_http_gzip_ok(ngx_http_request_t *r)
|
|
2120 {
|
|
2121 time_t date, expires;
|
|
2122 ngx_uint_t p;
|
|
2123 ngx_array_t *cc;
|
632
|
2124 ngx_table_elt_t *e, *d, *ae;
|
358
|
2125 ngx_http_core_loc_conf_t *clcf;
|
|
2126
|
546
|
2127 r->gzip_tested = 1;
|
358
|
2128
|
632
|
2129 if (r != r->main) {
|
|
2130 return NGX_DECLINED;
|
|
2131 }
|
|
2132
|
|
2133 ae = r->headers_in.accept_encoding;
|
|
2134 if (ae == NULL) {
|
|
2135 return NGX_DECLINED;
|
|
2136 }
|
|
2137
|
|
2138 if (ae->value.len < sizeof("gzip") - 1) {
|
|
2139 return NGX_DECLINED;
|
|
2140 }
|
|
2141
|
|
2142 /*
|
|
2143 * test first for the most common case "gzip,...":
|
|
2144 * MSIE: "gzip, deflate"
|
|
2145 * Firefox: "gzip,deflate"
|
|
2146 * Chrome: "gzip,deflate,sdch"
|
|
2147 * Safari: "gzip, deflate"
|
|
2148 * Opera: "gzip, deflate"
|
|
2149 */
|
|
2150
|
|
2151 if (ngx_memcmp(ae->value.data, "gzip,", 5) != 0
|
|
2152 && ngx_http_gzip_accept_encoding(&ae->value) != NGX_OK)
|
358
|
2153 {
|
|
2154 return NGX_DECLINED;
|
|
2155 }
|
|
2156
|
|
2157 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
|
2158
|
400
|
2159 if (r->headers_in.msie6 && clcf->gzip_disable_msie6) {
|
|
2160 return NGX_DECLINED;
|
|
2161 }
|
|
2162
|
358
|
2163 if (r->http_version < clcf->gzip_http_version) {
|
|
2164 return NGX_DECLINED;
|
|
2165 }
|
|
2166
|
|
2167 if (r->headers_in.via == NULL) {
|
|
2168 goto ok;
|
|
2169 }
|
|
2170
|
|
2171 p = clcf->gzip_proxied;
|
|
2172
|
|
2173 if (p & NGX_HTTP_GZIP_PROXIED_OFF) {
|
|
2174 return NGX_DECLINED;
|
|
2175 }
|
|
2176
|
|
2177 if (p & NGX_HTTP_GZIP_PROXIED_ANY) {
|
|
2178 goto ok;
|
|
2179 }
|
|
2180
|
|
2181 if (r->headers_in.authorization && (p & NGX_HTTP_GZIP_PROXIED_AUTH)) {
|
|
2182 goto ok;
|
|
2183 }
|
|
2184
|
|
2185 e = r->headers_out.expires;
|
|
2186
|
|
2187 if (e) {
|
|
2188
|
|
2189 if (!(p & NGX_HTTP_GZIP_PROXIED_EXPIRED)) {
|
|
2190 return NGX_DECLINED;
|
|
2191 }
|
|
2192
|
|
2193 expires = ngx_http_parse_time(e->value.data, e->value.len);
|
|
2194 if (expires == NGX_ERROR) {
|
|
2195 return NGX_DECLINED;
|
|
2196 }
|
|
2197
|
|
2198 d = r->headers_out.date;
|
|
2199
|
|
2200 if (d) {
|
|
2201 date = ngx_http_parse_time(d->value.data, d->value.len);
|
|
2202 if (date == NGX_ERROR) {
|
|
2203 return NGX_DECLINED;
|
|
2204 }
|
|
2205
|
|
2206 } else {
|
|
2207 date = ngx_time();
|
|
2208 }
|
|
2209
|
|
2210 if (expires < date) {
|
|
2211 goto ok;
|
|
2212 }
|
|
2213
|
|
2214 return NGX_DECLINED;
|
|
2215 }
|
|
2216
|
|
2217 cc = &r->headers_out.cache_control;
|
|
2218
|
|
2219 if (cc->elts) {
|
|
2220
|
|
2221 if ((p & NGX_HTTP_GZIP_PROXIED_NO_CACHE)
|
|
2222 && ngx_http_parse_multi_header_lines(cc, &ngx_http_gzip_no_cache,
|
|
2223 NULL)
|
|
2224 >= 0)
|
|
2225 {
|
|
2226 goto ok;
|
|
2227 }
|
|
2228
|
|
2229 if ((p & NGX_HTTP_GZIP_PROXIED_NO_STORE)
|
|
2230 && ngx_http_parse_multi_header_lines(cc, &ngx_http_gzip_no_store,
|
|
2231 NULL)
|
|
2232 >= 0)
|
|
2233 {
|
|
2234 goto ok;
|
|
2235 }
|
|
2236
|
|
2237 if ((p & NGX_HTTP_GZIP_PROXIED_PRIVATE)
|
|
2238 && ngx_http_parse_multi_header_lines(cc, &ngx_http_gzip_private,
|
|
2239 NULL)
|
|
2240 >= 0)
|
|
2241 {
|
|
2242 goto ok;
|
|
2243 }
|
|
2244
|
|
2245 return NGX_DECLINED;
|
|
2246 }
|
|
2247
|
|
2248 if ((p & NGX_HTTP_GZIP_PROXIED_NO_LM) && r->headers_out.last_modified) {
|
|
2249 return NGX_DECLINED;
|
|
2250 }
|
|
2251
|
|
2252 if ((p & NGX_HTTP_GZIP_PROXIED_NO_ETAG) && r->headers_out.etag) {
|
|
2253 return NGX_DECLINED;
|
|
2254 }
|
|
2255
|
|
2256 ok:
|
|
2257
|
|
2258 #if (NGX_PCRE)
|
|
2259
|
|
2260 if (clcf->gzip_disable && r->headers_in.user_agent) {
|
|
2261
|
362
|
2262 if (ngx_regex_exec_array(clcf->gzip_disable,
|
358
|
2263 &r->headers_in.user_agent->value,
|
|
2264 r->connection->log)
|
|
2265 != NGX_DECLINED)
|
|
2266 {
|
|
2267 return NGX_DECLINED;
|
|
2268 }
|
|
2269 }
|
|
2270
|
|
2271 #endif
|
|
2272
|
546
|
2273 r->gzip_ok = 1;
|
358
|
2274
|
|
2275 return NGX_OK;
|
|
2276 }
|
|
2277
|
632
|
2278
|
|
2279 /*
|
|
2280 * gzip is enabled for the following quantities:
|
634
|
2281 * "gzip; q=0.001" ... "gzip; q=1.000"
|
632
|
2282 * gzip is disabled for the following quantities:
|
|
2283 * "gzip; q=0" ... "gzip; q=0.000", and for any invalid cases
|
|
2284 */
|
|
2285
|
|
2286 static ngx_int_t
|
|
2287 ngx_http_gzip_accept_encoding(ngx_str_t *ae)
|
|
2288 {
|
634
|
2289 u_char *p, *start, *last;
|
632
|
2290
|
|
2291 start = ae->data;
|
|
2292 last = start + ae->len;
|
|
2293
|
|
2294 for ( ;; ) {
|
|
2295 p = ngx_strcasestrn(start, "gzip", 4 - 1);
|
|
2296 if (p == NULL) {
|
|
2297 return NGX_DECLINED;
|
|
2298 }
|
|
2299
|
|
2300 if (p == start || (*(p - 1) == ',' || *(p - 1) == ' ')) {
|
|
2301 break;
|
|
2302 }
|
|
2303
|
|
2304 start = p + 4;
|
|
2305 }
|
|
2306
|
|
2307 p += 4;
|
|
2308
|
|
2309 while (p < last) {
|
|
2310 switch(*p++) {
|
|
2311 case ',':
|
|
2312 return NGX_OK;
|
|
2313 case ';':
|
|
2314 goto quantity;
|
|
2315 case ' ':
|
|
2316 continue;
|
|
2317 default:
|
|
2318 return NGX_DECLINED;
|
|
2319 }
|
|
2320 }
|
|
2321
|
|
2322 return NGX_OK;
|
|
2323
|
|
2324 quantity:
|
|
2325
|
|
2326 while (p < last) {
|
|
2327 switch(*p++) {
|
|
2328 case 'q':
|
|
2329 case 'Q':
|
|
2330 goto equal;
|
|
2331 case ' ':
|
|
2332 continue;
|
|
2333 default:
|
|
2334 return NGX_DECLINED;
|
|
2335 }
|
|
2336 }
|
|
2337
|
|
2338 return NGX_OK;
|
|
2339
|
|
2340 equal:
|
|
2341
|
|
2342 if (p + 2 > last || *p++ != '=') {
|
|
2343 return NGX_DECLINED;
|
|
2344 }
|
|
2345
|
634
|
2346 if (ngx_http_gzip_quantity(p, last) == 0) {
|
632
|
2347 return NGX_DECLINED;
|
|
2348 }
|
|
2349
|
634
|
2350 return NGX_OK;
|
|
2351 }
|
|
2352
|
|
2353
|
|
2354 ngx_uint_t
|
|
2355 ngx_http_gzip_quantity(u_char *p, u_char *last)
|
|
2356 {
|
|
2357 u_char c;
|
|
2358 ngx_uint_t n, q;
|
|
2359
|
|
2360 c = *p++;
|
|
2361
|
|
2362 if (c != '0' && c != '1') {
|
|
2363 return 0;
|
632
|
2364 }
|
|
2365
|
634
|
2366 q = (c - '0') * 100;
|
|
2367
|
632
|
2368 if (p == last) {
|
634
|
2369 return q;
|
632
|
2370 }
|
|
2371
|
634
|
2372 c = *p++;
|
|
2373
|
|
2374 if (c == ',' || c == ' ') {
|
|
2375 return q;
|
|
2376 }
|
|
2377
|
|
2378 if (c != '.') {
|
|
2379 return 0;
|
632
|
2380 }
|
|
2381
|
|
2382 n = 0;
|
|
2383
|
|
2384 while (p < last) {
|
|
2385 c = *p++;
|
|
2386
|
634
|
2387 if (c == ',' || c == ' ') {
|
632
|
2388 break;
|
|
2389 }
|
|
2390
|
634
|
2391 if (c >= '0' && c <= '9') {
|
|
2392 q += c - '0';
|
632
|
2393 n++;
|
|
2394 continue;
|
|
2395 }
|
|
2396
|
634
|
2397 return 0;
|
632
|
2398 }
|
|
2399
|
634
|
2400 if (q > 100 || n > 3) {
|
|
2401 return 0;
|
632
|
2402 }
|
|
2403
|
634
|
2404 return q;
|
632
|
2405 }
|
|
2406
|
358
|
2407 #endif
|
|
2408
|
|
2409
|
88
|
2410 ngx_int_t
|
58
|
2411 ngx_http_subrequest(ngx_http_request_t *r,
|
244
|
2412 ngx_str_t *uri, ngx_str_t *args, ngx_http_request_t **psr,
|
248
|
2413 ngx_http_post_subrequest_t *ps, ngx_uint_t flags)
|
58
|
2414 {
|
590
|
2415 ngx_time_t *tp;
|
132
|
2416 ngx_connection_t *c;
|
58
|
2417 ngx_http_request_t *sr;
|
|
2418 ngx_http_core_srv_conf_t *cscf;
|
|
2419 ngx_http_postponed_request_t *pr, *p;
|
|
2420
|
206
|
2421 r->main->subrequests--;
|
|
2422
|
|
2423 if (r->main->subrequests == 0) {
|
|
2424 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
228
|
2425 "subrequests cycle while processing \"%V\"", uri);
|
256
|
2426 r->main->subrequests = 1;
|
206
|
2427 return NGX_ERROR;
|
|
2428 }
|
|
2429
|
58
|
2430 sr = ngx_pcalloc(r->pool, sizeof(ngx_http_request_t));
|
|
2431 if (sr == NULL) {
|
194
|
2432 return NGX_ERROR;
|
58
|
2433 }
|
|
2434
|
|
2435 sr->signature = NGX_HTTP_MODULE;
|
132
|
2436
|
|
2437 c = r->connection;
|
|
2438 sr->connection = c;
|
58
|
2439
|
|
2440 sr->ctx = ngx_pcalloc(r->pool, sizeof(void *) * ngx_http_max_module);
|
|
2441 if (sr->ctx == NULL) {
|
194
|
2442 return NGX_ERROR;
|
58
|
2443 }
|
|
2444
|
|
2445 if (ngx_list_init(&sr->headers_out.headers, r->pool, 20,
|
130
|
2446 sizeof(ngx_table_elt_t))
|
454
|
2447 != NGX_OK)
|
58
|
2448 {
|
194
|
2449 return NGX_ERROR;
|
58
|
2450 }
|
|
2451
|
|
2452 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
|
|
2453 sr->main_conf = cscf->ctx->main_conf;
|
|
2454 sr->srv_conf = cscf->ctx->srv_conf;
|
|
2455 sr->loc_conf = cscf->ctx->loc_conf;
|
|
2456
|
|
2457 sr->pool = r->pool;
|
|
2458
|
|
2459 sr->headers_in = r->headers_in;
|
|
2460
|
126
|
2461 ngx_http_clear_content_length(sr);
|
|
2462 ngx_http_clear_accept_ranges(sr);
|
|
2463 ngx_http_clear_last_modified(sr);
|
58
|
2464
|
|
2465 sr->request_body = r->request_body;
|
|
2466
|
|
2467 sr->method = NGX_HTTP_GET;
|
|
2468 sr->http_version = r->http_version;
|
|
2469
|
|
2470 sr->request_line = r->request_line;
|
|
2471 sr->uri = *uri;
|
122
|
2472
|
58
|
2473 if (args) {
|
|
2474 sr->args = *args;
|
|
2475 }
|
122
|
2476
|
132
|
2477 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
|
|
2478 "http subrequest \"%V?%V\"", uri, &sr->args);
|
|
2479
|
248
|
2480 sr->subrequest_in_memory = (flags & NGX_HTTP_SUBREQUEST_IN_MEMORY) != 0;
|
426
|
2481 sr->waited = (flags & NGX_HTTP_SUBREQUEST_WAITED) != 0;
|
122
|
2482
|
58
|
2483 sr->unparsed_uri = r->unparsed_uri;
|
364
|
2484 sr->method_name = ngx_http_core_get_method;
|
58
|
2485 sr->http_protocol = r->http_protocol;
|
|
2486
|
508
|
2487 ngx_http_set_exten(sr);
|
58
|
2488
|
102
|
2489 sr->main = r->main;
|
58
|
2490 sr->parent = r;
|
248
|
2491 sr->post_subrequest = ps;
|
58
|
2492 sr->read_event_handler = ngx_http_request_empty_handler;
|
426
|
2493 sr->write_event_handler = ngx_http_handler;
|
58
|
2494
|
434
|
2495 if (c->data == r && r->postponed == NULL) {
|
132
|
2496 c->data = sr;
|
58
|
2497 }
|
|
2498
|
|
2499 sr->variables = r->variables;
|
|
2500
|
|
2501 sr->log_handler = r->log_handler;
|
|
2502
|
|
2503 pr = ngx_palloc(r->pool, sizeof(ngx_http_postponed_request_t));
|
|
2504 if (pr == NULL) {
|
194
|
2505 return NGX_ERROR;
|
58
|
2506 }
|
|
2507
|
|
2508 pr->request = sr;
|
|
2509 pr->out = NULL;
|
|
2510 pr->next = NULL;
|
|
2511
|
|
2512 if (r->postponed) {
|
|
2513 for (p = r->postponed; p->next; p = p->next) { /* void */ }
|
|
2514 p->next = pr;
|
|
2515
|
|
2516 } else {
|
|
2517 r->postponed = pr;
|
|
2518 }
|
|
2519
|
|
2520 sr->internal = 1;
|
|
2521
|
92
|
2522 sr->discard_body = r->discard_body;
|
438
|
2523 sr->expect_tested = 1;
|
62
|
2524 sr->main_filter_need_in_memory = r->main_filter_need_in_memory;
|
|
2525
|
200
|
2526 sr->uri_changes = NGX_HTTP_MAX_URI_CHANGES + 1;
|
|
2527
|
590
|
2528 tp = ngx_timeofday();
|
622
|
2529 sr->start_sec = tp->sec;
|
|
2530 sr->start_msec = tp->msec;
|
590
|
2531
|
518
|
2532 r->main->count++;
|
426
|
2533
|
|
2534 *psr = sr;
|
|
2535
|
520
|
2536 return ngx_http_post_request(sr, NULL);
|
58
|
2537 }
|
|
2538
|
|
2539
|
|
2540 ngx_int_t
|
36
|
2541 ngx_http_internal_redirect(ngx_http_request_t *r,
|
|
2542 ngx_str_t *uri, ngx_str_t *args)
|
0
|
2543 {
|
36
|
2544 ngx_http_core_srv_conf_t *cscf;
|
|
2545
|
226
|
2546 r->uri_changes--;
|
|
2547
|
|
2548 if (r->uri_changes == 0) {
|
|
2549 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
228
|
2550 "rewrite or internal redirection cycle "
|
640
|
2551 "while internally redirecting to \"%V\"", uri);
|
228
|
2552
|
526
|
2553 r->main->count++;
|
226
|
2554 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
|
2555 return NGX_DONE;
|
|
2556 }
|
|
2557
|
10
|
2558 r->uri = *uri;
|
0
|
2559
|
|
2560 if (args) {
|
10
|
2561 r->args = *args;
|
58
|
2562
|
|
2563 } else {
|
570
|
2564 ngx_str_null(&r->args);
|
0
|
2565 }
|
|
2566
|
132
|
2567 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
2568 "internal redirect: \"%V?%V\"", uri, &r->args);
|
|
2569
|
508
|
2570 ngx_http_set_exten(r);
|
0
|
2571
|
224
|
2572 /* clear the modules contexts */
|
|
2573 ngx_memzero(r->ctx, sizeof(void *) * ngx_http_max_module);
|
0
|
2574
|
36
|
2575 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
|
|
2576 r->loc_conf = cscf->ctx->loc_conf;
|
|
2577
|
84
|
2578 ngx_http_update_location_config(r);
|
|
2579
|
464
|
2580 #if (NGX_HTTP_CACHE)
|
|
2581 r->cache = NULL;
|
|
2582 #endif
|
|
2583
|
58
|
2584 r->internal = 1;
|
656
|
2585 r->valid_unparsed_uri = 0;
|
574
|
2586 r->add_uri_to_alias = 0;
|
518
|
2587 r->main->count++;
|
58
|
2588
|
0
|
2589 ngx_http_handler(r);
|
|
2590
|
|
2591 return NGX_DONE;
|
|
2592 }
|
|
2593
|
|
2594
|
324
|
2595 ngx_int_t
|
|
2596 ngx_http_named_location(ngx_http_request_t *r, ngx_str_t *name)
|
|
2597 {
|
|
2598 ngx_http_core_srv_conf_t *cscf;
|
|
2599 ngx_http_core_loc_conf_t **clcfp;
|
|
2600 ngx_http_core_main_conf_t *cmcf;
|
|
2601
|
518
|
2602 r->main->count++;
|
662
|
2603 r->uri_changes--;
|
|
2604
|
|
2605 if (r->uri_changes == 0) {
|
|
2606 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
|
2607 "rewrite or internal redirection cycle "
|
|
2608 "while redirect to named location \"%V\"", name);
|
|
2609
|
|
2610 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
|
2611 return NGX_DONE;
|
|
2612 }
|
518
|
2613
|
324
|
2614 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
|
|
2615
|
430
|
2616 if (cscf->named_locations) {
|
|
2617
|
|
2618 for (clcfp = cscf->named_locations; *clcfp; clcfp++) {
|
|
2619
|
|
2620 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
2621 "test location: \"%V\"", &(*clcfp)->name);
|
|
2622
|
|
2623 if (name->len != (*clcfp)->name.len
|
|
2624 || ngx_strncmp(name->data, (*clcfp)->name.data, name->len) != 0)
|
|
2625 {
|
|
2626 continue;
|
|
2627 }
|
|
2628
|
|
2629 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
2630 "using location: %V \"%V?%V\"",
|
|
2631 name, &r->uri, &r->args);
|
|
2632
|
|
2633 r->internal = 1;
|
|
2634 r->content_handler = NULL;
|
680
|
2635 r->uri_changed = 0;
|
430
|
2636 r->loc_conf = (*clcfp)->loc_conf;
|
|
2637
|
644
|
2638 /* clear the modules contexts */
|
|
2639 ngx_memzero(r->ctx, sizeof(void *) * ngx_http_max_module);
|
|
2640
|
430
|
2641 ngx_http_update_location_config(r);
|
|
2642
|
|
2643 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
|
|
2644
|
|
2645 r->phase_handler = cmcf->phase_engine.location_rewrite_index;
|
|
2646
|
674
|
2647 r->write_event_handler = ngx_http_core_run_phases;
|
430
|
2648 ngx_http_core_run_phases(r);
|
|
2649
|
|
2650 return NGX_DONE;
|
324
|
2651 }
|
|
2652 }
|
|
2653
|
|
2654 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
342
|
2655 "could not find named location \"%V\"", name);
|
324
|
2656
|
|
2657 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
378
|
2658
|
324
|
2659 return NGX_DONE;
|
|
2660 }
|
|
2661
|
|
2662
|
118
|
2663 ngx_http_cleanup_t *
|
|
2664 ngx_http_cleanup_add(ngx_http_request_t *r, size_t size)
|
0
|
2665 {
|
118
|
2666 ngx_http_cleanup_t *cln;
|
|
2667
|
|
2668 r = r->main;
|
|
2669
|
|
2670 cln = ngx_palloc(r->pool, sizeof(ngx_http_cleanup_t));
|
|
2671 if (cln == NULL) {
|
|
2672 return NULL;
|
0
|
2673 }
|
|
2674
|
118
|
2675 if (size) {
|
|
2676 cln->data = ngx_palloc(r->pool, size);
|
|
2677 if (cln->data == NULL) {
|
|
2678 return NULL;
|
|
2679 }
|
|
2680
|
|
2681 } else {
|
|
2682 cln->data = NULL;
|
|
2683 }
|
|
2684
|
|
2685 cln->handler = NULL;
|
|
2686 cln->next = r->cleanup;
|
|
2687
|
|
2688 r->cleanup = cln;
|
|
2689
|
|
2690 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
2691 "http cleanup add: %p", cln);
|
|
2692
|
|
2693 return cln;
|
0
|
2694 }
|
|
2695
|
|
2696
|
664
|
2697 ngx_int_t
|
|
2698 ngx_http_set_disable_symlinks(ngx_http_request_t *r,
|
|
2699 ngx_http_core_loc_conf_t *clcf, ngx_str_t *path, ngx_open_file_info_t *of)
|
|
2700 {
|
|
2701 #if (NGX_HAVE_OPENAT)
|
|
2702 u_char *p;
|
|
2703 ngx_str_t from;
|
|
2704
|
|
2705 of->disable_symlinks = clcf->disable_symlinks;
|
|
2706
|
|
2707 if (clcf->disable_symlinks_from == NULL) {
|
|
2708 return NGX_OK;
|
|
2709 }
|
|
2710
|
|
2711 if (ngx_http_complex_value(r, clcf->disable_symlinks_from, &from)
|
|
2712 != NGX_OK)
|
|
2713 {
|
|
2714 return NGX_ERROR;
|
|
2715 }
|
|
2716
|
|
2717 if (from.len == 0
|
|
2718 || from.len > path->len
|
|
2719 || ngx_memcmp(path->data, from.data, from.len) != 0)
|
|
2720 {
|
|
2721 return NGX_OK;
|
|
2722 }
|
|
2723
|
|
2724 if (from.len == path->len) {
|
|
2725 of->disable_symlinks = NGX_DISABLE_SYMLINKS_OFF;
|
|
2726 return NGX_OK;
|
|
2727 }
|
|
2728
|
|
2729 p = path->data + from.len;
|
|
2730
|
|
2731 if (*p == '/') {
|
|
2732 of->disable_symlinks_from = from.len;
|
|
2733 return NGX_OK;
|
|
2734 }
|
|
2735
|
|
2736 p--;
|
|
2737
|
|
2738 if (*p == '/') {
|
|
2739 of->disable_symlinks_from = from.len - 1;
|
|
2740 }
|
|
2741 #endif
|
|
2742
|
|
2743 return NGX_OK;
|
|
2744 }
|
|
2745
|
|
2746
|
674
|
2747 ngx_int_t
|
|
2748 ngx_http_get_forwarded_addr(ngx_http_request_t *r, ngx_addr_t *addr,
|
|
2749 u_char *xff, size_t xfflen, ngx_array_t *proxies, int recursive)
|
|
2750 {
|
|
2751 u_char *p;
|
|
2752 in_addr_t inaddr;
|
|
2753 ngx_addr_t paddr;
|
|
2754 ngx_cidr_t *cidr;
|
|
2755 ngx_uint_t family, i;
|
|
2756 #if (NGX_HAVE_INET6)
|
|
2757 ngx_uint_t n;
|
|
2758 struct in6_addr *inaddr6;
|
|
2759 #endif
|
|
2760
|
|
2761 #if (NGX_SUPPRESS_WARN)
|
|
2762 inaddr = 0;
|
|
2763 #if (NGX_HAVE_INET6)
|
|
2764 inaddr6 = NULL;
|
|
2765 #endif
|
|
2766 #endif
|
|
2767
|
|
2768 family = addr->sockaddr->sa_family;
|
|
2769
|
|
2770 if (family == AF_INET) {
|
|
2771 inaddr = ((struct sockaddr_in *) addr->sockaddr)->sin_addr.s_addr;
|
|
2772 }
|
|
2773
|
|
2774 #if (NGX_HAVE_INET6)
|
|
2775 else if (family == AF_INET6) {
|
|
2776 inaddr6 = &((struct sockaddr_in6 *) addr->sockaddr)->sin6_addr;
|
|
2777
|
|
2778 if (IN6_IS_ADDR_V4MAPPED(inaddr6)) {
|
|
2779 family = AF_INET;
|
686
|
2780
|
|
2781 p = inaddr6->s6_addr;
|
|
2782
|
|
2783 inaddr = p[12] << 24;
|
|
2784 inaddr += p[13] << 16;
|
|
2785 inaddr += p[14] << 8;
|
|
2786 inaddr += p[15];
|
|
2787
|
|
2788 inaddr = htonl(inaddr);
|
674
|
2789 }
|
|
2790 }
|
|
2791 #endif
|
|
2792
|
|
2793 for (cidr = proxies->elts, i = 0; i < proxies->nelts; i++) {
|
|
2794 if (cidr[i].family != family) {
|
|
2795 goto next;
|
|
2796 }
|
|
2797
|
|
2798 switch (family) {
|
|
2799
|
|
2800 #if (NGX_HAVE_INET6)
|
|
2801 case AF_INET6:
|
|
2802 for (n = 0; n < 16; n++) {
|
|
2803 if ((inaddr6->s6_addr[n] & cidr[i].u.in6.mask.s6_addr[n])
|
|
2804 != cidr[i].u.in6.addr.s6_addr[n])
|
|
2805 {
|
|
2806 goto next;
|
|
2807 }
|
|
2808 }
|
|
2809 break;
|
|
2810 #endif
|
|
2811
|
|
2812 #if (NGX_HAVE_UNIX_DOMAIN)
|
|
2813 case AF_UNIX:
|
|
2814 break;
|
|
2815 #endif
|
|
2816
|
|
2817 default: /* AF_INET */
|
|
2818 if ((inaddr & cidr[i].u.in.mask) != cidr[i].u.in.addr) {
|
|
2819 goto next;
|
|
2820 }
|
|
2821 break;
|
|
2822 }
|
|
2823
|
|
2824 for (p = xff + xfflen - 1; p > xff; p--, xfflen--) {
|
|
2825 if (*p != ' ' && *p != ',') {
|
|
2826 break;
|
|
2827 }
|
|
2828 }
|
|
2829
|
|
2830 for ( /* void */ ; p > xff; p--) {
|
|
2831 if (*p == ' ' || *p == ',') {
|
|
2832 p++;
|
|
2833 break;
|
|
2834 }
|
|
2835 }
|
|
2836
|
|
2837 if (ngx_parse_addr(r->pool, &paddr, p, xfflen - (p - xff)) != NGX_OK) {
|
|
2838 return NGX_DECLINED;
|
|
2839 }
|
|
2840
|
|
2841 *addr = paddr;
|
|
2842
|
|
2843 if (recursive && p > xff) {
|
|
2844 (void) ngx_http_get_forwarded_addr(r, addr, xff, p - 1 - xff,
|
|
2845 proxies, 1);
|
|
2846 }
|
|
2847
|
|
2848 return NGX_OK;
|
|
2849
|
|
2850 next:
|
|
2851 continue;
|
|
2852 }
|
|
2853
|
|
2854 return NGX_DECLINED;
|
|
2855 }
|
|
2856
|
|
2857
|
36
|
2858 static char *
|
|
2859 ngx_http_core_server(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
|
0
|
2860 {
|
308
|
2861 char *rv;
|
|
2862 void *mconf;
|
310
|
2863 ngx_uint_t i;
|
308
|
2864 ngx_conf_t pcf;
|
|
2865 ngx_http_module_t *module;
|
602
|
2866 struct sockaddr_in *sin;
|
308
|
2867 ngx_http_conf_ctx_t *ctx, *http_ctx;
|
602
|
2868 ngx_http_listen_opt_t lsopt;
|
308
|
2869 ngx_http_core_srv_conf_t *cscf, **cscfp;
|
310
|
2870 ngx_http_core_main_conf_t *cmcf;
|
36
|
2871
|
50
|
2872 ctx = ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t));
|
|
2873 if (ctx == NULL) {
|
36
|
2874 return NGX_CONF_ERROR;
|
|
2875 }
|
0
|
2876
|
|
2877 http_ctx = cf->ctx;
|
|
2878 ctx->main_conf = http_ctx->main_conf;
|
|
2879
|
|
2880 /* the server{}'s srv_conf */
|
|
2881
|
36
|
2882 ctx->srv_conf = ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module);
|
|
2883 if (ctx->srv_conf == NULL) {
|
|
2884 return NGX_CONF_ERROR;
|
|
2885 }
|
0
|
2886
|
|
2887 /* the server{}'s loc_conf */
|
|
2888
|
36
|
2889 ctx->loc_conf = ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module);
|
|
2890 if (ctx->loc_conf == NULL) {
|
|
2891 return NGX_CONF_ERROR;
|
|
2892 }
|
0
|
2893
|
310
|
2894 for (i = 0; ngx_modules[i]; i++) {
|
|
2895 if (ngx_modules[i]->type != NGX_HTTP_MODULE) {
|
0
|
2896 continue;
|
|
2897 }
|
|
2898
|
310
|
2899 module = ngx_modules[i]->ctx;
|
0
|
2900
|
|
2901 if (module->create_srv_conf) {
|
50
|
2902 mconf = module->create_srv_conf(cf);
|
|
2903 if (mconf == NULL) {
|
36
|
2904 return NGX_CONF_ERROR;
|
|
2905 }
|
|
2906
|
310
|
2907 ctx->srv_conf[ngx_modules[i]->ctx_index] = mconf;
|
0
|
2908 }
|
|
2909
|
|
2910 if (module->create_loc_conf) {
|
50
|
2911 mconf = module->create_loc_conf(cf);
|
|
2912 if (mconf == NULL) {
|
36
|
2913 return NGX_CONF_ERROR;
|
|
2914 }
|
|
2915
|
310
|
2916 ctx->loc_conf[ngx_modules[i]->ctx_index] = mconf;
|
0
|
2917 }
|
|
2918 }
|
|
2919
|
36
|
2920
|
|
2921 /* the server configuration context */
|
0
|
2922
|
|
2923 cscf = ctx->srv_conf[ngx_http_core_module.ctx_index];
|
|
2924 cscf->ctx = ctx;
|
|
2925
|
36
|
2926
|
0
|
2927 cmcf = ctx->main_conf[ngx_http_core_module.ctx_index];
|
36
|
2928
|
50
|
2929 cscfp = ngx_array_push(&cmcf->servers);
|
|
2930 if (cscfp == NULL) {
|
36
|
2931 return NGX_CONF_ERROR;
|
|
2932 }
|
|
2933
|
0
|
2934 *cscfp = cscf;
|
|
2935
|
36
|
2936
|
0
|
2937 /* parse inside server{} */
|
|
2938
|
70
|
2939 pcf = *cf;
|
0
|
2940 cf->ctx = ctx;
|
|
2941 cf->cmd_type = NGX_HTTP_SRV_CONF;
|
34
|
2942
|
0
|
2943 rv = ngx_conf_parse(cf, NULL);
|
34
|
2944
|
70
|
2945 *cf = pcf;
|
0
|
2946
|
602
|
2947 if (rv == NGX_CONF_OK && !cscf->listen) {
|
|
2948 ngx_memzero(&lsopt, sizeof(ngx_http_listen_opt_t));
|
|
2949
|
|
2950 sin = &lsopt.u.sockaddr_in;
|
|
2951
|
|
2952 sin->sin_family = AF_INET;
|
|
2953 #if (NGX_WIN32)
|
|
2954 sin->sin_port = htons(80);
|
|
2955 #else
|
|
2956 sin->sin_port = htons((getuid() == 0) ? 80 : 8000);
|
|
2957 #endif
|
|
2958 sin->sin_addr.s_addr = INADDR_ANY;
|
|
2959
|
|
2960 lsopt.socklen = sizeof(struct sockaddr_in);
|
|
2961
|
|
2962 lsopt.backlog = NGX_LISTEN_BACKLOG;
|
|
2963 lsopt.rcvbuf = -1;
|
|
2964 lsopt.sndbuf = -1;
|
|
2965 #if (NGX_HAVE_SETFIB)
|
|
2966 lsopt.setfib = -1;
|
|
2967 #endif
|
|
2968 lsopt.wildcard = 1;
|
|
2969
|
|
2970 (void) ngx_sock_ntop(&lsopt.u.sockaddr, lsopt.addr,
|
|
2971 NGX_SOCKADDR_STRLEN, 1);
|
|
2972
|
|
2973 if (ngx_http_add_listen(cf, cscf, &lsopt) != NGX_OK) {
|
|
2974 return NGX_CONF_ERROR;
|
|
2975 }
|
|
2976 }
|
|
2977
|
0
|
2978 return rv;
|
|
2979 }
|
|
2980
|
|
2981
|
36
|
2982 static char *
|
|
2983 ngx_http_core_location(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
|
0
|
2984 {
|
|
2985 char *rv;
|
430
|
2986 u_char *mod;
|
|
2987 size_t len;
|
|
2988 ngx_str_t *value, *name;
|
310
|
2989 ngx_uint_t i;
|
34
|
2990 ngx_conf_t save;
|
0
|
2991 ngx_http_module_t *module;
|
|
2992 ngx_http_conf_ctx_t *ctx, *pctx;
|
378
|
2993 ngx_http_core_loc_conf_t *clcf, *pclcf;
|
0
|
2994
|
50
|
2995 ctx = ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t));
|
|
2996 if (ctx == NULL) {
|
0
|
2997 return NGX_CONF_ERROR;
|
|
2998 }
|
|
2999
|
|
3000 pctx = cf->ctx;
|
|
3001 ctx->main_conf = pctx->main_conf;
|
|
3002 ctx->srv_conf = pctx->srv_conf;
|
|
3003
|
|
3004 ctx->loc_conf = ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module);
|
|
3005 if (ctx->loc_conf == NULL) {
|
|
3006 return NGX_CONF_ERROR;
|
|
3007 }
|
|
3008
|
310
|
3009 for (i = 0; ngx_modules[i]; i++) {
|
|
3010 if (ngx_modules[i]->type != NGX_HTTP_MODULE) {
|
0
|
3011 continue;
|
|
3012 }
|
|
3013
|
310
|
3014 module = ngx_modules[i]->ctx;
|
0
|
3015
|
|
3016 if (module->create_loc_conf) {
|
310
|
3017 ctx->loc_conf[ngx_modules[i]->ctx_index] =
|
0
|
3018 module->create_loc_conf(cf);
|
310
|
3019 if (ctx->loc_conf[ngx_modules[i]->ctx_index] == NULL) {
|
0
|
3020 return NGX_CONF_ERROR;
|
|
3021 }
|
|
3022 }
|
|
3023 }
|
|
3024
|
|
3025 clcf = ctx->loc_conf[ngx_http_core_module.ctx_index];
|
|
3026 clcf->loc_conf = ctx->loc_conf;
|
|
3027
|
|
3028 value = cf->args->elts;
|
|
3029
|
|
3030 if (cf->args->nelts == 3) {
|
430
|
3031
|
|
3032 len = value[1].len;
|
|
3033 mod = value[1].data;
|
|
3034 name = &value[2];
|
|
3035
|
|
3036 if (len == 1 && mod[0] == '=') {
|
|
3037
|
|
3038 clcf->name = *name;
|
0
|
3039 clcf->exact_match = 1;
|
|
3040
|
430
|
3041 } else if (len == 2 && mod[0] == '^' && mod[1] == '~') {
|
|
3042
|
|
3043 clcf->name = *name;
|
16
|
3044 clcf->noregex = 1;
|
|
3045
|
430
|
3046 } else if (len == 1 && mod[0] == '~') {
|
|
3047
|
|
3048 if (ngx_http_core_regex_location(cf, clcf, name, 0) != NGX_OK) {
|
0
|
3049 return NGX_CONF_ERROR;
|
|
3050 }
|
|
3051
|
430
|
3052 } else if (len == 2 && mod[0] == '~' && mod[1] == '*') {
|
|
3053
|
|
3054 if (ngx_http_core_regex_location(cf, clcf, name, 1) != NGX_OK) {
|
|
3055 return NGX_CONF_ERROR;
|
|
3056 }
|
0
|
3057
|
|
3058 } else {
|
|
3059 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
10
|
3060 "invalid location modifier \"%V\"", &value[1]);
|
0
|
3061 return NGX_CONF_ERROR;
|
|
3062 }
|
|
3063
|
|
3064 } else {
|
324
|
3065
|
430
|
3066 name = &value[1];
|
|
3067
|
|
3068 if (name->data[0] == '=') {
|
|
3069
|
|
3070 clcf->name.len = name->len - 1;
|
|
3071 clcf->name.data = name->data + 1;
|
|
3072 clcf->exact_match = 1;
|
|
3073
|
|
3074 } else if (name->data[0] == '^' && name->data[1] == '~') {
|
|
3075
|
|
3076 clcf->name.len = name->len - 2;
|
|
3077 clcf->name.data = name->data + 2;
|
|
3078 clcf->noregex = 1;
|
|
3079
|
|
3080 } else if (name->data[0] == '~') {
|
|
3081
|
|
3082 name->len--;
|
|
3083 name->data++;
|
|
3084
|
|
3085 if (name->data[0] == '*') {
|
|
3086
|
|
3087 name->len--;
|
|
3088 name->data++;
|
|
3089
|
|
3090 if (ngx_http_core_regex_location(cf, clcf, name, 1) != NGX_OK) {
|
|
3091 return NGX_CONF_ERROR;
|
|
3092 }
|
|
3093
|
|
3094 } else {
|
|
3095 if (ngx_http_core_regex_location(cf, clcf, name, 0) != NGX_OK) {
|
|
3096 return NGX_CONF_ERROR;
|
|
3097 }
|
|
3098 }
|
|
3099
|
|
3100 } else {
|
|
3101
|
|
3102 clcf->name = *name;
|
|
3103
|
|
3104 if (name->data[0] == '@') {
|
|
3105 clcf->named = 1;
|
|
3106 }
|
324
|
3107 }
|
0
|
3108 }
|
|
3109
|
|
3110 pclcf = pctx->loc_conf[ngx_http_core_module.ctx_index];
|
|
3111
|
378
|
3112 if (pclcf->name.len) {
|
|
3113
|
|
3114 /* nested location */
|
|
3115
|
34
|
3116 #if 0
|
0
|
3117 clcf->prev_location = pclcf;
|
34
|
3118 #endif
|
0
|
3119
|
|
3120 if (pclcf->exact_match) {
|
|
3121 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
640
|
3122 "location \"%V\" cannot be inside "
|
10
|
3123 "the exact location \"%V\"",
|
|
3124 &clcf->name, &pclcf->name);
|
0
|
3125 return NGX_CONF_ERROR;
|
|
3126 }
|
|
3127
|
324
|
3128 if (pclcf->named) {
|
|
3129 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
640
|
3130 "location \"%V\" cannot be inside "
|
324
|
3131 "the named location \"%V\"",
|
|
3132 &clcf->name, &pclcf->name);
|
|
3133 return NGX_CONF_ERROR;
|
|
3134 }
|
|
3135
|
378
|
3136 if (clcf->named) {
|
|
3137 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
640
|
3138 "named location \"%V\" can be "
|
|
3139 "on the server level only",
|
378
|
3140 &clcf->name);
|
|
3141 return NGX_CONF_ERROR;
|
|
3142 }
|
|
3143
|
430
|
3144 len = pclcf->name.len;
|
|
3145
|
4
|
3146 #if (NGX_PCRE)
|
0
|
3147 if (clcf->regex == NULL
|
430
|
3148 && ngx_strncmp(clcf->name.data, pclcf->name.data, len) != 0)
|
0
|
3149 #else
|
430
|
3150 if (ngx_strncmp(clcf->name.data, pclcf->name.data, len) != 0)
|
0
|
3151 #endif
|
|
3152 {
|
|
3153 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
10
|
3154 "location \"%V\" is outside location \"%V\"",
|
|
3155 &clcf->name, &pclcf->name);
|
0
|
3156 return NGX_CONF_ERROR;
|
|
3157 }
|
|
3158 }
|
|
3159
|
378
|
3160 if (ngx_http_add_location(cf, &pclcf->locations, clcf) != NGX_OK) {
|
|
3161 return NGX_CONF_ERROR;
|
|
3162 }
|
0
|
3163
|
34
|
3164 save = *cf;
|
0
|
3165 cf->ctx = ctx;
|
|
3166 cf->cmd_type = NGX_HTTP_LOC_CONF;
|
34
|
3167
|
0
|
3168 rv = ngx_conf_parse(cf, NULL);
|
34
|
3169
|
|
3170 *cf = save;
|
|
3171
|
0
|
3172 return rv;
|
|
3173 }
|
|
3174
|
|
3175
|
430
|
3176 static ngx_int_t
|
|
3177 ngx_http_core_regex_location(ngx_conf_t *cf, ngx_http_core_loc_conf_t *clcf,
|
|
3178 ngx_str_t *regex, ngx_uint_t caseless)
|
|
3179 {
|
|
3180 #if (NGX_PCRE)
|
546
|
3181 ngx_regex_compile_t rc;
|
|
3182 u_char errstr[NGX_MAX_CONF_ERRSTR];
|
|
3183
|
|
3184 ngx_memzero(&rc, sizeof(ngx_regex_compile_t));
|
|
3185
|
|
3186 rc.pattern = *regex;
|
|
3187 rc.err.len = NGX_MAX_CONF_ERRSTR;
|
|
3188 rc.err.data = errstr;
|
430
|
3189
|
508
|
3190 #if (NGX_HAVE_CASELESS_FILESYSTEM)
|
546
|
3191 rc.options = NGX_REGEX_CASELESS;
|
558
|
3192 #else
|
|
3193 rc.options = caseless;
|
508
|
3194 #endif
|
|
3195
|
546
|
3196 clcf->regex = ngx_http_regex_compile(cf, &rc);
|
430
|
3197 if (clcf->regex == NULL) {
|
|
3198 return NGX_ERROR;
|
|
3199 }
|
|
3200
|
|
3201 clcf->name = *regex;
|
|
3202
|
|
3203 return NGX_OK;
|
|
3204
|
|
3205 #else
|
|
3206
|
|
3207 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
640
|
3208 "using regex \"%V\" requires PCRE library",
|
430
|
3209 regex);
|
|
3210 return NGX_ERROR;
|
|
3211
|
|
3212 #endif
|
|
3213 }
|
|
3214
|
|
3215
|
36
|
3216 static char *
|
|
3217 ngx_http_core_types(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
0
|
3218 {
|
546
|
3219 ngx_http_core_loc_conf_t *clcf = conf;
|
186
|
3220
|
0
|
3221 char *rv;
|
34
|
3222 ngx_conf_t save;
|
0
|
3223
|
546
|
3224 if (clcf->types == NULL) {
|
|
3225 clcf->types = ngx_array_create(cf->pool, 64, sizeof(ngx_hash_key_t));
|
|
3226 if (clcf->types == NULL) {
|
186
|
3227 return NGX_CONF_ERROR;
|
|
3228 }
|
|
3229 }
|
|
3230
|
34
|
3231 save = *cf;
|
|
3232 cf->handler = ngx_http_core_type;
|
0
|
3233 cf->handler_conf = conf;
|
34
|
3234
|
0
|
3235 rv = ngx_conf_parse(cf, NULL);
|
34
|
3236
|
|
3237 *cf = save;
|
0
|
3238
|
|
3239 return rv;
|
|
3240 }
|
|
3241
|
|
3242
|
36
|
3243 static char *
|
|
3244 ngx_http_core_type(ngx_conf_t *cf, ngx_command_t *dummy, void *conf)
|
0
|
3245 {
|
546
|
3246 ngx_http_core_loc_conf_t *clcf = conf;
|
0
|
3247
|
686
|
3248 ngx_str_t *value, *content_type, *old;
|
392
|
3249 ngx_uint_t i, n, hash;
|
138
|
3250 ngx_hash_key_t *type;
|
0
|
3251
|
294
|
3252 value = cf->args->elts;
|
|
3253
|
|
3254 if (ngx_strcmp(value[0].data, "include") == 0) {
|
644
|
3255 if (cf->args->nelts != 2) {
|
|
3256 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
3257 "invalid number of arguments"
|
|
3258 " in \"include\" directive");
|
|
3259 return NGX_CONF_ERROR;
|
|
3260 }
|
686
|
3261
|
|
3262 return ngx_conf_include(cf, dummy, conf);
|
294
|
3263 }
|
|
3264
|
138
|
3265 content_type = ngx_palloc(cf->pool, sizeof(ngx_str_t));
|
|
3266 if (content_type == NULL) {
|
|
3267 return NGX_CONF_ERROR;
|
0
|
3268 }
|
|
3269
|
138
|
3270 *content_type = value[0];
|
0
|
3271
|
|
3272 for (i = 1; i < cf->args->nelts; i++) {
|
138
|
3273
|
392
|
3274 hash = ngx_hash_strlow(value[i].data, value[i].data, value[i].len);
|
138
|
3275
|
546
|
3276 type = clcf->types->elts;
|
|
3277 for (n = 0; n < clcf->types->nelts; n++) {
|
138
|
3278 if (ngx_strcmp(value[i].data, type[n].key.data) == 0) {
|
|
3279 old = type[n].value;
|
|
3280 type[n].value = content_type;
|
|
3281
|
|
3282 ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
|
640
|
3283 "duplicate extension \"%V\", "
|
138
|
3284 "content type: \"%V\", "
|
640
|
3285 "previous content type: \"%V\"",
|
138
|
3286 &value[i], content_type, old);
|
644
|
3287 goto next;
|
138
|
3288 }
|
|
3289 }
|
|
3290
|
|
3291
|
546
|
3292 type = ngx_array_push(clcf->types);
|
50
|
3293 if (type == NULL) {
|
0
|
3294 return NGX_CONF_ERROR;
|
|
3295 }
|
|
3296
|
138
|
3297 type->key = value[i];
|
392
|
3298 type->key_hash = hash;
|
138
|
3299 type->value = content_type;
|
644
|
3300
|
|
3301 next:
|
|
3302 continue;
|
0
|
3303 }
|
|
3304
|
|
3305 return NGX_CONF_OK;
|
|
3306 }
|
|
3307
|
|
3308
|
58
|
3309 static ngx_int_t
|
|
3310 ngx_http_core_preconfiguration(ngx_conf_t *cf)
|
|
3311 {
|
|
3312 return ngx_http_variables_add_core_vars(cf);
|
|
3313 }
|
|
3314
|
|
3315
|
36
|
3316 static void *
|
|
3317 ngx_http_core_create_main_conf(ngx_conf_t *cf)
|
0
|
3318 {
|
34
|
3319 ngx_http_core_main_conf_t *cmcf;
|
|
3320
|
50
|
3321 cmcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_core_main_conf_t));
|
|
3322 if (cmcf == NULL) {
|
496
|
3323 return NULL;
|
34
|
3324 }
|
0
|
3325
|
48
|
3326 if (ngx_array_init(&cmcf->servers, cf->pool, 4,
|
118
|
3327 sizeof(ngx_http_core_srv_conf_t *))
|
200
|
3328 != NGX_OK)
|
34
|
3329 {
|
496
|
3330 return NULL;
|
34
|
3331 }
|
0
|
3332
|
142
|
3333 cmcf->server_names_hash_max_size = NGX_CONF_UNSET_UINT;
|
|
3334 cmcf->server_names_hash_bucket_size = NGX_CONF_UNSET_UINT;
|
26
|
3335
|
160
|
3336 cmcf->variables_hash_max_size = NGX_CONF_UNSET_UINT;
|
|
3337 cmcf->variables_hash_bucket_size = NGX_CONF_UNSET_UINT;
|
|
3338
|
0
|
3339 return cmcf;
|
|
3340 }
|
|
3341
|
|
3342
|
36
|
3343 static char *
|
|
3344 ngx_http_core_init_main_conf(ngx_conf_t *cf, void *conf)
|
0
|
3345 {
|
|
3346 ngx_http_core_main_conf_t *cmcf = conf;
|
|
3347
|
142
|
3348 if (cmcf->server_names_hash_max_size == NGX_CONF_UNSET_UINT) {
|
|
3349 cmcf->server_names_hash_max_size = 512;
|
26
|
3350 }
|
|
3351
|
142
|
3352 if (cmcf->server_names_hash_bucket_size == NGX_CONF_UNSET_UINT) {
|
|
3353 cmcf->server_names_hash_bucket_size = ngx_cacheline_size;
|
26
|
3354 }
|
0
|
3355
|
142
|
3356 cmcf->server_names_hash_bucket_size =
|
|
3357 ngx_align(cmcf->server_names_hash_bucket_size, ngx_cacheline_size);
|
|
3358
|
160
|
3359
|
|
3360 if (cmcf->variables_hash_max_size == NGX_CONF_UNSET_UINT) {
|
|
3361 cmcf->variables_hash_max_size = 512;
|
|
3362 }
|
|
3363
|
|
3364 if (cmcf->variables_hash_bucket_size == NGX_CONF_UNSET_UINT) {
|
|
3365 cmcf->variables_hash_bucket_size = 64;
|
|
3366 }
|
|
3367
|
|
3368 cmcf->variables_hash_bucket_size =
|
|
3369 ngx_align(cmcf->variables_hash_bucket_size, ngx_cacheline_size);
|
|
3370
|
548
|
3371 if (cmcf->ncaptures) {
|
|
3372 cmcf->ncaptures = (cmcf->ncaptures + 1) * 3;
|
|
3373 }
|
|
3374
|
0
|
3375 return NGX_CONF_OK;
|
|
3376 }
|
|
3377
|
|
3378
|
36
|
3379 static void *
|
|
3380 ngx_http_core_create_srv_conf(ngx_conf_t *cf)
|
0
|
3381 {
|
|
3382 ngx_http_core_srv_conf_t *cscf;
|
|
3383
|
50
|
3384 cscf = ngx_pcalloc(cf->pool, sizeof(ngx_http_core_srv_conf_t));
|
|
3385 if (cscf == NULL) {
|
496
|
3386 return NULL;
|
36
|
3387 }
|
|
3388
|
0
|
3389 /*
|
36
|
3390 * set by ngx_pcalloc():
|
28
|
3391 *
|
|
3392 * conf->client_large_buffers.num = 0;
|
|
3393 */
|
0
|
3394
|
230
|
3395 if (ngx_array_init(&cscf->server_names, cf->temp_pool, 4,
|
142
|
3396 sizeof(ngx_http_server_name_t))
|
454
|
3397 != NGX_OK)
|
36
|
3398 {
|
496
|
3399 return NULL;
|
36
|
3400 }
|
0
|
3401
|
|
3402 cscf->connection_pool_size = NGX_CONF_UNSET_SIZE;
|
|
3403 cscf->request_pool_size = NGX_CONF_UNSET_SIZE;
|
|
3404 cscf->client_header_timeout = NGX_CONF_UNSET_MSEC;
|
|
3405 cscf->client_header_buffer_size = NGX_CONF_UNSET_SIZE;
|
60
|
3406 cscf->ignore_invalid_headers = NGX_CONF_UNSET;
|
342
|
3407 cscf->merge_slashes = NGX_CONF_UNSET;
|
412
|
3408 cscf->underscores_in_headers = NGX_CONF_UNSET;
|
0
|
3409
|
|
3410 return cscf;
|
|
3411 }
|
|
3412
|
|
3413
|
36
|
3414 static char *
|
|
3415 ngx_http_core_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
|
0
|
3416 {
|
|
3417 ngx_http_core_srv_conf_t *prev = parent;
|
|
3418 ngx_http_core_srv_conf_t *conf = child;
|
|
3419
|
612
|
3420 ngx_str_t name;
|
142
|
3421 ngx_http_server_name_t *sn;
|
0
|
3422
|
|
3423 /* TODO: it does not merge, it inits only */
|
|
3424
|
540
|
3425 ngx_conf_merge_size_value(conf->connection_pool_size,
|
|
3426 prev->connection_pool_size, 256);
|
|
3427 ngx_conf_merge_size_value(conf->request_pool_size,
|
|
3428 prev->request_pool_size, 4096);
|
|
3429 ngx_conf_merge_msec_value(conf->client_header_timeout,
|
|
3430 prev->client_header_timeout, 60000);
|
|
3431 ngx_conf_merge_size_value(conf->client_header_buffer_size,
|
|
3432 prev->client_header_buffer_size, 1024);
|
|
3433 ngx_conf_merge_bufs_value(conf->large_client_header_buffers,
|
|
3434 prev->large_client_header_buffers,
|
556
|
3435 4, 8192);
|
540
|
3436
|
|
3437 if (conf->large_client_header_buffers.size < conf->connection_pool_size) {
|
|
3438 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
3439 "the \"large_client_header_buffers\" size must be "
|
640
|
3440 "equal to or greater than \"connection_pool_size\"");
|
540
|
3441 return NGX_CONF_ERROR;
|
|
3442 }
|
|
3443
|
|
3444 ngx_conf_merge_value(conf->ignore_invalid_headers,
|
|
3445 prev->ignore_invalid_headers, 1);
|
|
3446
|
|
3447 ngx_conf_merge_value(conf->merge_slashes, prev->merge_slashes, 1);
|
|
3448
|
|
3449 ngx_conf_merge_value(conf->underscores_in_headers,
|
|
3450 prev->underscores_in_headers, 0);
|
|
3451
|
612
|
3452 if (conf->server_names.nelts == 0) {
|
640
|
3453 /* the array has 4 empty preallocated elements, so push cannot fail */
|
50
|
3454 sn = ngx_array_push(&conf->server_names);
|
342
|
3455 #if (NGX_PCRE)
|
|
3456 sn->regex = NULL;
|
|
3457 #endif
|
538
|
3458 sn->server = conf;
|
592
|
3459 ngx_str_set(&sn->name, "");
|
0
|
3460 }
|
|
3461
|
612
|
3462 sn = conf->server_names.elts;
|
|
3463 name = sn[0].name;
|
|
3464
|
|
3465 #if (NGX_PCRE)
|
|
3466 if (sn->regex) {
|
|
3467 name.len++;
|
|
3468 name.data--;
|
|
3469 } else
|
|
3470 #endif
|
|
3471
|
|
3472 if (name.data[0] == '.') {
|
|
3473 name.len--;
|
|
3474 name.data++;
|
|
3475 }
|
|
3476
|
|
3477 conf->server_name.len = name.len;
|
|
3478 conf->server_name.data = ngx_pstrdup(cf->pool, &name);
|
|
3479 if (conf->server_name.data == NULL) {
|
|
3480 return NGX_CONF_ERROR;
|
|
3481 }
|
|
3482
|
0
|
3483 return NGX_CONF_OK;
|
|
3484 }
|
|
3485
|
|
3486
|
36
|
3487 static void *
|
|
3488 ngx_http_core_create_loc_conf(ngx_conf_t *cf)
|
0
|
3489 {
|
546
|
3490 ngx_http_core_loc_conf_t *clcf;
|
|
3491
|
|
3492 clcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_core_loc_conf_t));
|
|
3493 if (clcf == NULL) {
|
496
|
3494 return NULL;
|
36
|
3495 }
|
0
|
3496
|
28
|
3497 /*
|
|
3498 * set by ngx_pcalloc():
|
|
3499 *
|
546
|
3500 * clcf->root = { 0, NULL };
|
|
3501 * clcf->limit_except = 0;
|
|
3502 * clcf->post_action = { 0, NULL };
|
|
3503 * clcf->types = NULL;
|
|
3504 * clcf->default_type = { 0, NULL };
|
|
3505 * clcf->error_log = NULL;
|
|
3506 * clcf->error_pages = NULL;
|
|
3507 * clcf->try_files = NULL;
|
|
3508 * clcf->client_body_path = NULL;
|
|
3509 * clcf->regex = NULL;
|
|
3510 * clcf->exact_match = 0;
|
|
3511 * clcf->auto_redirect = 0;
|
|
3512 * clcf->alias = 0;
|
|
3513 * clcf->gzip_proxied = 0;
|
650
|
3514 * clcf->keepalive_disable = 0;
|
28
|
3515 */
|
0
|
3516
|
546
|
3517 clcf->client_max_body_size = NGX_CONF_UNSET;
|
|
3518 clcf->client_body_buffer_size = NGX_CONF_UNSET_SIZE;
|
|
3519 clcf->client_body_timeout = NGX_CONF_UNSET_MSEC;
|
|
3520 clcf->satisfy = NGX_CONF_UNSET_UINT;
|
|
3521 clcf->if_modified_since = NGX_CONF_UNSET_UINT;
|
636
|
3522 clcf->max_ranges = NGX_CONF_UNSET_UINT;
|
546
|
3523 clcf->client_body_in_file_only = NGX_CONF_UNSET_UINT;
|
|
3524 clcf->client_body_in_single_buffer = NGX_CONF_UNSET;
|
|
3525 clcf->internal = NGX_CONF_UNSET;
|
|
3526 clcf->sendfile = NGX_CONF_UNSET;
|
|
3527 clcf->sendfile_max_chunk = NGX_CONF_UNSET_SIZE;
|
518
|
3528 #if (NGX_HAVE_FILE_AIO)
|
546
|
3529 clcf->aio = NGX_CONF_UNSET;
|
518
|
3530 #endif
|
546
|
3531 clcf->read_ahead = NGX_CONF_UNSET_SIZE;
|
|
3532 clcf->directio = NGX_CONF_UNSET;
|
|
3533 clcf->directio_alignment = NGX_CONF_UNSET;
|
|
3534 clcf->tcp_nopush = NGX_CONF_UNSET;
|
|
3535 clcf->tcp_nodelay = NGX_CONF_UNSET;
|
|
3536 clcf->send_timeout = NGX_CONF_UNSET_MSEC;
|
|
3537 clcf->send_lowat = NGX_CONF_UNSET_SIZE;
|
|
3538 clcf->postpone_output = NGX_CONF_UNSET_SIZE;
|
|
3539 clcf->limit_rate = NGX_CONF_UNSET_SIZE;
|
|
3540 clcf->limit_rate_after = NGX_CONF_UNSET_SIZE;
|
|
3541 clcf->keepalive_timeout = NGX_CONF_UNSET_MSEC;
|
|
3542 clcf->keepalive_header = NGX_CONF_UNSET;
|
|
3543 clcf->keepalive_requests = NGX_CONF_UNSET_UINT;
|
632
|
3544 clcf->lingering_close = NGX_CONF_UNSET_UINT;
|
546
|
3545 clcf->lingering_time = NGX_CONF_UNSET_MSEC;
|
|
3546 clcf->lingering_timeout = NGX_CONF_UNSET_MSEC;
|
|
3547 clcf->resolver_timeout = NGX_CONF_UNSET_MSEC;
|
|
3548 clcf->reset_timedout_connection = NGX_CONF_UNSET;
|
|
3549 clcf->server_name_in_redirect = NGX_CONF_UNSET;
|
|
3550 clcf->port_in_redirect = NGX_CONF_UNSET;
|
|
3551 clcf->msie_padding = NGX_CONF_UNSET;
|
|
3552 clcf->msie_refresh = NGX_CONF_UNSET;
|
|
3553 clcf->log_not_found = NGX_CONF_UNSET;
|
|
3554 clcf->log_subrequest = NGX_CONF_UNSET;
|
|
3555 clcf->recursive_error_pages = NGX_CONF_UNSET;
|
|
3556 clcf->server_tokens = NGX_CONF_UNSET;
|
566
|
3557 clcf->chunked_transfer_encoding = NGX_CONF_UNSET;
|
680
|
3558 clcf->etag = NGX_CONF_UNSET;
|
546
|
3559 clcf->types_hash_max_size = NGX_CONF_UNSET_UINT;
|
|
3560 clcf->types_hash_bucket_size = NGX_CONF_UNSET_UINT;
|
|
3561
|
|
3562 clcf->open_file_cache = NGX_CONF_UNSET_PTR;
|
|
3563 clcf->open_file_cache_valid = NGX_CONF_UNSET;
|
|
3564 clcf->open_file_cache_min_uses = NGX_CONF_UNSET_UINT;
|
|
3565 clcf->open_file_cache_errors = NGX_CONF_UNSET;
|
|
3566 clcf->open_file_cache_events = NGX_CONF_UNSET;
|
0
|
3567
|
358
|
3568 #if (NGX_HTTP_GZIP)
|
546
|
3569 clcf->gzip_vary = NGX_CONF_UNSET;
|
|
3570 clcf->gzip_http_version = NGX_CONF_UNSET_UINT;
|
362
|
3571 #if (NGX_PCRE)
|
546
|
3572 clcf->gzip_disable = NGX_CONF_UNSET_PTR;
|
596
|
3573 #endif
|
546
|
3574 clcf->gzip_disable_msie6 = 3;
|
602
|
3575 #if (NGX_HTTP_DEGRADATION)
|
|
3576 clcf->gzip_disable_degradation = 3;
|
|
3577 #endif
|
358
|
3578 #endif
|
|
3579
|
662
|
3580 #if (NGX_HAVE_OPENAT)
|
|
3581 clcf->disable_symlinks = NGX_CONF_UNSET_UINT;
|
664
|
3582 clcf->disable_symlinks_from = NGX_CONF_UNSET_PTR;
|
662
|
3583 #endif
|
|
3584
|
546
|
3585 return clcf;
|
0
|
3586 }
|
|
3587
|
|
3588
|
138
|
3589 static ngx_str_t ngx_http_core_text_html_type = ngx_string("text/html");
|
|
3590 static ngx_str_t ngx_http_core_image_gif_type = ngx_string("image/gif");
|
|
3591 static ngx_str_t ngx_http_core_image_jpeg_type = ngx_string("image/jpeg");
|
|
3592
|
|
3593 static ngx_hash_key_t ngx_http_core_default_types[] = {
|
|
3594 { ngx_string("html"), 0, &ngx_http_core_text_html_type },
|
|
3595 { ngx_string("gif"), 0, &ngx_http_core_image_gif_type },
|
|
3596 { ngx_string("jpg"), 0, &ngx_http_core_image_jpeg_type },
|
|
3597 { ngx_null_string, 0, NULL }
|
0
|
3598 };
|
|
3599
|
|
3600
|
36
|
3601 static char *
|
138
|
3602 ngx_http_core_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
0
|
3603 {
|
|
3604 ngx_http_core_loc_conf_t *prev = parent;
|
|
3605 ngx_http_core_loc_conf_t *conf = child;
|
|
3606
|
36
|
3607 ngx_uint_t i;
|
138
|
3608 ngx_hash_key_t *type;
|
|
3609 ngx_hash_init_t types_hash;
|
0
|
3610
|
152
|
3611 if (conf->root.data == NULL) {
|
|
3612
|
174
|
3613 conf->alias = prev->alias;
|
152
|
3614 conf->root = prev->root;
|
|
3615 conf->root_lengths = prev->root_lengths;
|
|
3616 conf->root_values = prev->root_values;
|
|
3617
|
|
3618 if (prev->root.data == NULL) {
|
570
|
3619 ngx_str_set(&conf->root, "html");
|
152
|
3620
|
454
|
3621 if (ngx_conf_full_name(cf->cycle, &conf->root, 0) != NGX_OK) {
|
152
|
3622 return NGX_CONF_ERROR;
|
|
3623 }
|
|
3624 }
|
0
|
3625 }
|
|
3626
|
126
|
3627 if (conf->post_action.data == NULL) {
|
|
3628 conf->post_action = prev->post_action;
|
|
3629 }
|
|
3630
|
212
|
3631 ngx_conf_merge_uint_value(conf->types_hash_max_size,
|
|
3632 prev->types_hash_max_size, 1024);
|
|
3633
|
|
3634 ngx_conf_merge_uint_value(conf->types_hash_bucket_size,
|
|
3635 prev->types_hash_bucket_size,
|
|
3636 ngx_cacheline_size);
|
138
|
3637
|
|
3638 conf->types_hash_bucket_size = ngx_align(conf->types_hash_bucket_size,
|
|
3639 ngx_cacheline_size);
|
|
3640
|
|
3641 /*
|
644
|
3642 * the special handling of the "types" directive in the "http" section
|
138
|
3643 * to inherit the http's conf->types_hash to all servers
|
|
3644 */
|
|
3645
|
|
3646 if (prev->types && prev->types_hash.buckets == NULL) {
|
|
3647
|
|
3648 types_hash.hash = &prev->types_hash;
|
|
3649 types_hash.key = ngx_hash_key_lc;
|
|
3650 types_hash.max_size = conf->types_hash_max_size;
|
|
3651 types_hash.bucket_size = conf->types_hash_bucket_size;
|
144
|
3652 types_hash.name = "types_hash";
|
138
|
3653 types_hash.pool = cf->pool;
|
|
3654 types_hash.temp_pool = NULL;
|
|
3655
|
|
3656 if (ngx_hash_init(&types_hash, prev->types->elts, prev->types->nelts)
|
|
3657 != NGX_OK)
|
|
3658 {
|
|
3659 return NGX_CONF_ERROR;
|
|
3660 }
|
|
3661 }
|
|
3662
|
0
|
3663 if (conf->types == NULL) {
|
138
|
3664 conf->types = prev->types;
|
|
3665 conf->types_hash = prev->types_hash;
|
|
3666 }
|
|
3667
|
|
3668 if (conf->types == NULL) {
|
644
|
3669 conf->types = ngx_array_create(cf->pool, 3, sizeof(ngx_hash_key_t));
|
138
|
3670 if (conf->types == NULL) {
|
|
3671 return NGX_CONF_ERROR;
|
|
3672 }
|
|
3673
|
|
3674 for (i = 0; ngx_http_core_default_types[i].key.len; i++) {
|
|
3675 type = ngx_array_push(conf->types);
|
|
3676 if (type == NULL) {
|
36
|
3677 return NGX_CONF_ERROR;
|
|
3678 }
|
0
|
3679
|
138
|
3680 type->key = ngx_http_core_default_types[i].key;
|
|
3681 type->key_hash =
|
|
3682 ngx_hash_key_lc(ngx_http_core_default_types[i].key.data,
|
|
3683 ngx_http_core_default_types[i].key.len);
|
|
3684 type->value = ngx_http_core_default_types[i].value;
|
|
3685 }
|
|
3686 }
|
|
3687
|
|
3688 if (conf->types_hash.buckets == NULL) {
|
|
3689
|
|
3690 types_hash.hash = &conf->types_hash;
|
|
3691 types_hash.key = ngx_hash_key_lc;
|
|
3692 types_hash.max_size = conf->types_hash_max_size;
|
|
3693 types_hash.bucket_size = conf->types_hash_bucket_size;
|
644
|
3694 types_hash.name = "types_hash";
|
138
|
3695 types_hash.pool = cf->pool;
|
|
3696 types_hash.temp_pool = NULL;
|
|
3697
|
|
3698 if (ngx_hash_init(&types_hash, conf->types->elts, conf->types->nelts)
|
|
3699 != NGX_OK)
|
|
3700 {
|
|
3701 return NGX_CONF_ERROR;
|
0
|
3702 }
|
|
3703 }
|
|
3704
|
484
|
3705 if (conf->error_log == NULL) {
|
|
3706 if (prev->error_log) {
|
|
3707 conf->error_log = prev->error_log;
|
0
|
3708 } else {
|
484
|
3709 conf->error_log = &cf->cycle->new_log;
|
0
|
3710 }
|
|
3711 }
|
|
3712
|
|
3713 if (conf->error_pages == NULL && prev->error_pages) {
|
|
3714 conf->error_pages = prev->error_pages;
|
|
3715 }
|
|
3716
|
|
3717 ngx_conf_merge_str_value(conf->default_type,
|
36
|
3718 prev->default_type, "text/plain");
|
0
|
3719
|
212
|
3720 ngx_conf_merge_off_value(conf->client_max_body_size,
|
0
|
3721 prev->client_max_body_size, 1 * 1024 * 1024);
|
|
3722 ngx_conf_merge_size_value(conf->client_body_buffer_size,
|
|
3723 prev->client_body_buffer_size,
|
|
3724 (size_t) 2 * ngx_pagesize);
|
|
3725 ngx_conf_merge_msec_value(conf->client_body_timeout,
|
|
3726 prev->client_body_timeout, 60000);
|
58
|
3727
|
648
|
3728 ngx_conf_merge_bitmask_value(conf->keepalive_disable,
|
|
3729 prev->keepalive_disable,
|
|
3730 (NGX_CONF_BITMASK_SET
|
668
|
3731 |NGX_HTTP_KEEPALIVE_DISABLE_MSIE6));
|
362
|
3732 ngx_conf_merge_uint_value(conf->satisfy, prev->satisfy,
|
|
3733 NGX_HTTP_SATISFY_ALL);
|
424
|
3734 ngx_conf_merge_uint_value(conf->if_modified_since, prev->if_modified_since,
|
444
|
3735 NGX_HTTP_IMS_EXACT);
|
636
|
3736 ngx_conf_merge_uint_value(conf->max_ranges, prev->max_ranges,
|
644
|
3737 NGX_MAX_INT32_VALUE);
|
492
|
3738 ngx_conf_merge_uint_value(conf->client_body_in_file_only,
|
644
|
3739 prev->client_body_in_file_only,
|
|
3740 NGX_HTTP_REQUEST_BODY_FILE_OFF);
|
492
|
3741 ngx_conf_merge_value(conf->client_body_in_single_buffer,
|
|
3742 prev->client_body_in_single_buffer, 0);
|
58
|
3743 ngx_conf_merge_value(conf->internal, prev->internal, 0);
|
0
|
3744 ngx_conf_merge_value(conf->sendfile, prev->sendfile, 0);
|
300
|
3745 ngx_conf_merge_size_value(conf->sendfile_max_chunk,
|
|
3746 prev->sendfile_max_chunk, 0);
|
518
|
3747 #if (NGX_HAVE_FILE_AIO)
|
644
|
3748 ngx_conf_merge_value(conf->aio, prev->aio, NGX_HTTP_AIO_OFF);
|
518
|
3749 #endif
|
532
|
3750 ngx_conf_merge_size_value(conf->read_ahead, prev->read_ahead, 0);
|
390
|
3751 ngx_conf_merge_off_value(conf->directio, prev->directio,
|
644
|
3752 NGX_OPEN_FILE_DIRECTIO_OFF);
|
518
|
3753 ngx_conf_merge_off_value(conf->directio_alignment, prev->directio_alignment,
|
|
3754 512);
|
0
|
3755 ngx_conf_merge_value(conf->tcp_nopush, prev->tcp_nopush, 0);
|
228
|
3756 ngx_conf_merge_value(conf->tcp_nodelay, prev->tcp_nodelay, 1);
|
58
|
3757
|
0
|
3758 ngx_conf_merge_msec_value(conf->send_timeout, prev->send_timeout, 60000);
|
|
3759 ngx_conf_merge_size_value(conf->send_lowat, prev->send_lowat, 0);
|
|
3760 ngx_conf_merge_size_value(conf->postpone_output, prev->postpone_output,
|
|
3761 1460);
|
|
3762 ngx_conf_merge_size_value(conf->limit_rate, prev->limit_rate, 0);
|
496
|
3763 ngx_conf_merge_size_value(conf->limit_rate_after, prev->limit_rate_after,
|
|
3764 0);
|
0
|
3765 ngx_conf_merge_msec_value(conf->keepalive_timeout,
|
|
3766 prev->keepalive_timeout, 75000);
|
|
3767 ngx_conf_merge_sec_value(conf->keepalive_header,
|
|
3768 prev->keepalive_header, 0);
|
496
|
3769 ngx_conf_merge_uint_value(conf->keepalive_requests,
|
|
3770 prev->keepalive_requests, 100);
|
634
|
3771 ngx_conf_merge_uint_value(conf->lingering_close,
|
632
|
3772 prev->lingering_close, NGX_HTTP_LINGERING_ON);
|
0
|
3773 ngx_conf_merge_msec_value(conf->lingering_time,
|
|
3774 prev->lingering_time, 30000);
|
|
3775 ngx_conf_merge_msec_value(conf->lingering_timeout,
|
|
3776 prev->lingering_timeout, 5000);
|
348
|
3777 ngx_conf_merge_msec_value(conf->resolver_timeout,
|
|
3778 prev->resolver_timeout, 30000);
|
|
3779
|
|
3780 if (conf->resolver == NULL) {
|
366
|
3781
|
|
3782 if (prev->resolver == NULL) {
|
|
3783
|
|
3784 /*
|
|
3785 * create dummy resolver in http {} context
|
|
3786 * to inherit it in all servers
|
|
3787 */
|
|
3788
|
646
|
3789 prev->resolver = ngx_resolver_create(cf, NULL, 0);
|
366
|
3790 if (prev->resolver == NULL) {
|
364
|
3791 return NGX_CONF_ERROR;
|
354
|
3792 }
|
|
3793 }
|
376
|
3794
|
366
|
3795 conf->resolver = prev->resolver;
|
348
|
3796 }
|
0
|
3797
|
464
|
3798 if (ngx_conf_merge_path_value(cf, &conf->client_body_temp_path,
|
28
|
3799 prev->client_body_temp_path,
|
464
|
3800 &ngx_http_client_temp_path)
|
|
3801 != NGX_OK)
|
|
3802 {
|
|
3803 return NGX_CONF_ERROR;
|
|
3804 }
|
28
|
3805
|
0
|
3806 ngx_conf_merge_value(conf->reset_timedout_connection,
|
36
|
3807 prev->reset_timedout_connection, 0);
|
362
|
3808 ngx_conf_merge_value(conf->server_name_in_redirect,
|
592
|
3809 prev->server_name_in_redirect, 0);
|
70
|
3810 ngx_conf_merge_value(conf->port_in_redirect, prev->port_in_redirect, 1);
|
0
|
3811 ngx_conf_merge_value(conf->msie_padding, prev->msie_padding, 1);
|
228
|
3812 ngx_conf_merge_value(conf->msie_refresh, prev->msie_refresh, 0);
|
76
|
3813 ngx_conf_merge_value(conf->log_not_found, prev->log_not_found, 1);
|
412
|
3814 ngx_conf_merge_value(conf->log_subrequest, prev->log_subrequest, 0);
|
228
|
3815 ngx_conf_merge_value(conf->recursive_error_pages,
|
|
3816 prev->recursive_error_pages, 0);
|
342
|
3817 ngx_conf_merge_value(conf->server_tokens, prev->server_tokens, 1);
|
566
|
3818 ngx_conf_merge_value(conf->chunked_transfer_encoding,
|
|
3819 prev->chunked_transfer_encoding, 1);
|
680
|
3820 ngx_conf_merge_value(conf->etag, prev->etag, 1);
|
0
|
3821
|
332
|
3822 ngx_conf_merge_ptr_value(conf->open_file_cache,
|
358
|
3823 prev->open_file_cache, NULL);
|
|
3824
|
|
3825 ngx_conf_merge_sec_value(conf->open_file_cache_valid,
|
|
3826 prev->open_file_cache_valid, 60);
|
|
3827
|
|
3828 ngx_conf_merge_uint_value(conf->open_file_cache_min_uses,
|
|
3829 prev->open_file_cache_min_uses, 1);
|
332
|
3830
|
|
3831 ngx_conf_merge_sec_value(conf->open_file_cache_errors,
|
358
|
3832 prev->open_file_cache_errors, 0);
|
332
|
3833
|
|
3834 ngx_conf_merge_sec_value(conf->open_file_cache_events,
|
358
|
3835 prev->open_file_cache_events, 0);
|
|
3836 #if (NGX_HTTP_GZIP)
|
|
3837
|
|
3838 ngx_conf_merge_value(conf->gzip_vary, prev->gzip_vary, 0);
|
|
3839 ngx_conf_merge_uint_value(conf->gzip_http_version, prev->gzip_http_version,
|
|
3840 NGX_HTTP_VERSION_11);
|
|
3841 ngx_conf_merge_bitmask_value(conf->gzip_proxied, prev->gzip_proxied,
|
|
3842 (NGX_CONF_BITMASK_SET|NGX_HTTP_GZIP_PROXIED_OFF));
|
|
3843
|
362
|
3844 #if (NGX_PCRE)
|
358
|
3845 ngx_conf_merge_ptr_value(conf->gzip_disable, prev->gzip_disable, NULL);
|
362
|
3846 #endif
|
358
|
3847
|
400
|
3848 if (conf->gzip_disable_msie6 == 3) {
|
|
3849 conf->gzip_disable_msie6 =
|
|
3850 (prev->gzip_disable_msie6 == 3) ? 0 : prev->gzip_disable_msie6;
|
|
3851 }
|
|
3852
|
602
|
3853 #if (NGX_HTTP_DEGRADATION)
|
|
3854
|
|
3855 if (conf->gzip_disable_degradation == 3) {
|
|
3856 conf->gzip_disable_degradation =
|
|
3857 (prev->gzip_disable_degradation == 3) ?
|
|
3858 0 : prev->gzip_disable_degradation;
|
|
3859 }
|
|
3860
|
|
3861 #endif
|
358
|
3862 #endif
|
0
|
3863
|
662
|
3864 #if (NGX_HAVE_OPENAT)
|
|
3865 ngx_conf_merge_uint_value(conf->disable_symlinks, prev->disable_symlinks,
|
|
3866 NGX_DISABLE_SYMLINKS_OFF);
|
664
|
3867 ngx_conf_merge_ptr_value(conf->disable_symlinks_from,
|
|
3868 prev->disable_symlinks_from, NULL);
|
662
|
3869 #endif
|
|
3870
|
0
|
3871 return NGX_CONF_OK;
|
|
3872 }
|
|
3873
|
|
3874
|
36
|
3875 static char *
|
|
3876 ngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
0
|
3877 {
|
538
|
3878 ngx_http_core_srv_conf_t *cscf = conf;
|
|
3879
|
|
3880 ngx_str_t *value, size;
|
|
3881 ngx_url_t u;
|
|
3882 ngx_uint_t n;
|
|
3883 ngx_http_listen_opt_t lsopt;
|
|
3884
|
|
3885 cscf->listen = 1;
|
0
|
3886
|
72
|
3887 value = cf->args->elts;
|
126
|
3888
|
252
|
3889 ngx_memzero(&u, sizeof(ngx_url_t));
|
|
3890
|
|
3891 u.url = value[1];
|
|
3892 u.listen = 1;
|
266
|
3893 u.default_port = 80;
|
252
|
3894
|
340
|
3895 if (ngx_parse_url(cf->pool, &u) != NGX_OK) {
|
252
|
3896 if (u.err) {
|
|
3897 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
3898 "%s in \"%V\" of the \"listen\" directive",
|
|
3899 u.err, &u.url);
|
|
3900 }
|
|
3901
|
126
|
3902 return NGX_CONF_ERROR;
|
72
|
3903 }
|
|
3904
|
538
|
3905 ngx_memzero(&lsopt, sizeof(ngx_http_listen_opt_t));
|
|
3906
|
558
|
3907 ngx_memcpy(&lsopt.u.sockaddr, u.sockaddr, u.socklen);
|
538
|
3908
|
|
3909 lsopt.socklen = u.socklen;
|
|
3910 lsopt.backlog = NGX_LISTEN_BACKLOG;
|
|
3911 lsopt.rcvbuf = -1;
|
|
3912 lsopt.sndbuf = -1;
|
584
|
3913 #if (NGX_HAVE_SETFIB)
|
|
3914 lsopt.setfib = -1;
|
|
3915 #endif
|
538
|
3916 lsopt.wildcard = u.wildcard;
|
682
|
3917 #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
|
|
3918 lsopt.ipv6only = 1;
|
|
3919 #endif
|
538
|
3920
|
558
|
3921 (void) ngx_sock_ntop(&lsopt.u.sockaddr, lsopt.addr,
|
448
|
3922 NGX_SOCKADDR_STRLEN, 1);
|
180
|
3923
|
538
|
3924 for (n = 2; n < cf->args->nelts; n++) {
|
|
3925
|
|
3926 if (ngx_strcmp(value[n].data, "default_server") == 0
|
|
3927 || ngx_strcmp(value[n].data, "default") == 0)
|
|
3928 {
|
|
3929 lsopt.default_server = 1;
|
|
3930 continue;
|
72
|
3931 }
|
|
3932
|
|
3933 if (ngx_strcmp(value[n].data, "bind") == 0) {
|
538
|
3934 lsopt.set = 1;
|
|
3935 lsopt.bind = 1;
|
72
|
3936 continue;
|
|
3937 }
|
|
3938
|
584
|
3939 #if (NGX_HAVE_SETFIB)
|
|
3940 if (ngx_strncmp(value[n].data, "setfib=", 7) == 0) {
|
|
3941 lsopt.setfib = ngx_atoi(value[n].data + 7, value[n].len - 7);
|
|
3942
|
586
|
3943 if (lsopt.setfib == NGX_ERROR) {
|
584
|
3944 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
3945 "invalid setfib \"%V\"", &value[n]);
|
|
3946 return NGX_CONF_ERROR;
|
|
3947 }
|
|
3948
|
|
3949 continue;
|
|
3950 }
|
|
3951 #endif
|
112
|
3952 if (ngx_strncmp(value[n].data, "backlog=", 8) == 0) {
|
538
|
3953 lsopt.backlog = ngx_atoi(value[n].data + 8, value[n].len - 8);
|
|
3954 lsopt.set = 1;
|
|
3955 lsopt.bind = 1;
|
|
3956
|
|
3957 if (lsopt.backlog == NGX_ERROR || lsopt.backlog == 0) {
|
72
|
3958 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
3959 "invalid backlog \"%V\"", &value[n]);
|
|
3960 return NGX_CONF_ERROR;
|
|
3961 }
|
|
3962
|
|
3963 continue;
|
|
3964 }
|
|
3965
|
112
|
3966 if (ngx_strncmp(value[n].data, "rcvbuf=", 7) == 0) {
|
|
3967 size.len = value[n].len - 7;
|
|
3968 size.data = value[n].data + 7;
|
|
3969
|
538
|
3970 lsopt.rcvbuf = ngx_parse_size(&size);
|
|
3971 lsopt.set = 1;
|
|
3972 lsopt.bind = 1;
|
|
3973
|
|
3974 if (lsopt.rcvbuf == NGX_ERROR) {
|
112
|
3975 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
3976 "invalid rcvbuf \"%V\"", &value[n]);
|
|
3977 return NGX_CONF_ERROR;
|
|
3978 }
|
|
3979
|
|
3980 continue;
|
|
3981 }
|
|
3982
|
|
3983 if (ngx_strncmp(value[n].data, "sndbuf=", 7) == 0) {
|
|
3984 size.len = value[n].len - 7;
|
|
3985 size.data = value[n].data + 7;
|
|
3986
|
538
|
3987 lsopt.sndbuf = ngx_parse_size(&size);
|
|
3988 lsopt.set = 1;
|
|
3989 lsopt.bind = 1;
|
|
3990
|
|
3991 if (lsopt.sndbuf == NGX_ERROR) {
|
112
|
3992 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
3993 "invalid sndbuf \"%V\"", &value[n]);
|
|
3994 return NGX_CONF_ERROR;
|
|
3995 }
|
|
3996
|
|
3997 continue;
|
|
3998 }
|
|
3999
|
|
4000 if (ngx_strncmp(value[n].data, "accept_filter=", 14) == 0) {
|
72
|
4001 #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
|
538
|
4002 lsopt.accept_filter = (char *) &value[n].data[14];
|
|
4003 lsopt.set = 1;
|
|
4004 lsopt.bind = 1;
|
72
|
4005 #else
|
|
4006 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
4007 "accept filters \"%V\" are not supported "
|
|
4008 "on this platform, ignored",
|
|
4009 &value[n]);
|
|
4010 #endif
|
|
4011 continue;
|
|
4012 }
|
|
4013
|
|
4014 if (ngx_strcmp(value[n].data, "deferred") == 0) {
|
|
4015 #if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)
|
538
|
4016 lsopt.deferred_accept = 1;
|
|
4017 lsopt.set = 1;
|
|
4018 lsopt.bind = 1;
|
72
|
4019 #else
|
|
4020 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
4021 "the deferred accept is not supported "
|
|
4022 "on this platform, ignored");
|
|
4023 #endif
|
|
4024 continue;
|
|
4025 }
|
0
|
4026
|
460
|
4027 if (ngx_strncmp(value[n].data, "ipv6only=o", 10) == 0) {
|
|
4028 #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
|
|
4029 struct sockaddr *sa;
|
|
4030
|
558
|
4031 sa = &lsopt.u.sockaddr;
|
460
|
4032
|
|
4033 if (sa->sa_family == AF_INET6) {
|
|
4034
|
|
4035 if (ngx_strcmp(&value[n].data[10], "n") == 0) {
|
538
|
4036 lsopt.ipv6only = 1;
|
460
|
4037
|
|
4038 } else if (ngx_strcmp(&value[n].data[10], "ff") == 0) {
|
682
|
4039 lsopt.ipv6only = 0;
|
460
|
4040
|
|
4041 } else {
|
|
4042 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
4043 "invalid ipv6only flags \"%s\"",
|
|
4044 &value[n].data[9]);
|
|
4045 return NGX_CONF_ERROR;
|
|
4046 }
|
|
4047
|
538
|
4048 lsopt.set = 1;
|
|
4049 lsopt.bind = 1;
|
460
|
4050
|
|
4051 } else {
|
|
4052 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
4053 "ipv6only is not supported "
|
538
|
4054 "on addr \"%s\", ignored", lsopt.addr);
|
460
|
4055 }
|
|
4056
|
|
4057 continue;
|
|
4058 #else
|
|
4059 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
640
|
4060 "ipv6only is not supported "
|
460
|
4061 "on this platform");
|
|
4062 return NGX_CONF_ERROR;
|
|
4063 #endif
|
|
4064 }
|
|
4065
|
404
|
4066 if (ngx_strcmp(value[n].data, "ssl") == 0) {
|
|
4067 #if (NGX_HTTP_SSL)
|
538
|
4068 lsopt.ssl = 1;
|
404
|
4069 continue;
|
|
4070 #else
|
|
4071 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
4072 "the \"ssl\" parameter requires "
|
|
4073 "ngx_http_ssl_module");
|
|
4074 return NGX_CONF_ERROR;
|
|
4075 #endif
|
|
4076 }
|
|
4077
|
654
|
4078 if (ngx_strncmp(value[n].data, "so_keepalive=", 13) == 0) {
|
|
4079
|
|
4080 if (ngx_strcmp(&value[n].data[13], "on") == 0) {
|
|
4081 lsopt.so_keepalive = 1;
|
|
4082
|
|
4083 } else if (ngx_strcmp(&value[n].data[13], "off") == 0) {
|
|
4084 lsopt.so_keepalive = 2;
|
|
4085
|
|
4086 } else {
|
|
4087
|
|
4088 #if (NGX_HAVE_KEEPALIVE_TUNABLE)
|
|
4089 u_char *p, *end;
|
|
4090 ngx_str_t s;
|
|
4091
|
|
4092 end = value[n].data + value[n].len;
|
|
4093 s.data = value[n].data + 13;
|
|
4094
|
|
4095 p = ngx_strlchr(s.data, end, ':');
|
|
4096 if (p == NULL) {
|
|
4097 p = end;
|
|
4098 }
|
|
4099
|
|
4100 if (p > s.data) {
|
|
4101 s.len = p - s.data;
|
|
4102
|
|
4103 lsopt.tcp_keepidle = ngx_parse_time(&s, 1);
|
662
|
4104 if (lsopt.tcp_keepidle == (time_t) NGX_ERROR) {
|
654
|
4105 goto invalid_so_keepalive;
|
|
4106 }
|
|
4107 }
|
|
4108
|
|
4109 s.data = (p < end) ? (p + 1) : end;
|
|
4110
|
|
4111 p = ngx_strlchr(s.data, end, ':');
|
|
4112 if (p == NULL) {
|
|
4113 p = end;
|
|
4114 }
|
|
4115
|
|
4116 if (p > s.data) {
|
|
4117 s.len = p - s.data;
|
|
4118
|
|
4119 lsopt.tcp_keepintvl = ngx_parse_time(&s, 1);
|
662
|
4120 if (lsopt.tcp_keepintvl == (time_t) NGX_ERROR) {
|
654
|
4121 goto invalid_so_keepalive;
|
|
4122 }
|
|
4123 }
|
|
4124
|
|
4125 s.data = (p < end) ? (p + 1) : end;
|
|
4126
|
|
4127 if (s.data < end) {
|
|
4128 s.len = end - s.data;
|
|
4129
|
|
4130 lsopt.tcp_keepcnt = ngx_atoi(s.data, s.len);
|
|
4131 if (lsopt.tcp_keepcnt == NGX_ERROR) {
|
|
4132 goto invalid_so_keepalive;
|
|
4133 }
|
|
4134 }
|
|
4135
|
666
|
4136 if (lsopt.tcp_keepidle == 0 && lsopt.tcp_keepintvl == 0
|
654
|
4137 && lsopt.tcp_keepcnt == 0)
|
|
4138 {
|
|
4139 goto invalid_so_keepalive;
|
|
4140 }
|
|
4141
|
|
4142 lsopt.so_keepalive = 1;
|
|
4143
|
|
4144 #else
|
|
4145
|
|
4146 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
4147 "the \"so_keepalive\" parameter accepts "
|
|
4148 "only \"on\" or \"off\" on this platform");
|
|
4149 return NGX_CONF_ERROR;
|
|
4150
|
|
4151 #endif
|
|
4152 }
|
|
4153
|
|
4154 lsopt.set = 1;
|
|
4155 lsopt.bind = 1;
|
|
4156
|
|
4157 continue;
|
|
4158
|
|
4159 #if (NGX_HAVE_KEEPALIVE_TUNABLE)
|
|
4160 invalid_so_keepalive:
|
|
4161
|
|
4162 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
4163 "invalid so_keepalive value: \"%s\"",
|
|
4164 &value[n].data[13]);
|
|
4165 return NGX_CONF_ERROR;
|
|
4166 #endif
|
|
4167 }
|
|
4168
|
0
|
4169 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
640
|
4170 "invalid parameter \"%V\"", &value[n]);
|
0
|
4171 return NGX_CONF_ERROR;
|
|
4172 }
|
|
4173
|
538
|
4174 if (ngx_http_add_listen(cf, cscf, &lsopt) == NGX_OK) {
|
|
4175 return NGX_CONF_OK;
|
|
4176 }
|
|
4177
|
|
4178 return NGX_CONF_ERROR;
|
0
|
4179 }
|
|
4180
|
|
4181
|
36
|
4182 static char *
|
|
4183 ngx_http_core_server_name(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
0
|
4184 {
|
142
|
4185 ngx_http_core_srv_conf_t *cscf = conf;
|
|
4186
|
|
4187 u_char ch;
|
612
|
4188 ngx_str_t *value;
|
142
|
4189 ngx_uint_t i;
|
|
4190 ngx_http_server_name_t *sn;
|
0
|
4191
|
|
4192 value = cf->args->elts;
|
|
4193
|
142
|
4194 for (i = 1; i < cf->args->nelts; i++) {
|
|
4195
|
|
4196 ch = value[i].data[0];
|
|
4197
|
400
|
4198 if ((ch == '*' && (value[i].len < 3 || value[i].data[1] != '.'))
|
142
|
4199 || (ch == '.' && value[i].len < 2))
|
|
4200 {
|
|
4201 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
4202 "server name \"%V\" is invalid", &value[i]);
|
|
4203 return NGX_CONF_ERROR;
|
|
4204 }
|
|
4205
|
294
|
4206 if (ngx_strchr(value[i].data, '/')) {
|
|
4207 ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
|
640
|
4208 "server name \"%V\" has suspicious symbols",
|
294
|
4209 &value[i]);
|
|
4210 }
|
|
4211
|
142
|
4212 sn = ngx_array_push(&cscf->server_names);
|
50
|
4213 if (sn == NULL) {
|
4
|
4214 return NGX_CONF_ERROR;
|
|
4215 }
|
0
|
4216
|
326
|
4217 #if (NGX_PCRE)
|
|
4218 sn->regex = NULL;
|
|
4219 #endif
|
538
|
4220 sn->server = cscf;
|
612
|
4221
|
|
4222 if (ngx_strcasecmp(value[i].data, (u_char *) "$hostname") == 0) {
|
|
4223 sn->name = cf->cycle->hostname;
|
|
4224
|
|
4225 } else {
|
|
4226 sn->name = value[i];
|
|
4227 }
|
326
|
4228
|
|
4229 if (value[i].data[0] != '~') {
|
554
|
4230 ngx_strlow(sn->name.data, sn->name.data, sn->name.len);
|
326
|
4231 continue;
|
|
4232 }
|
|
4233
|
|
4234 #if (NGX_PCRE)
|
356
|
4235 {
|
554
|
4236 u_char *p;
|
|
4237 ngx_regex_compile_t rc;
|
|
4238 u_char errstr[NGX_MAX_CONF_ERRSTR];
|
356
|
4239
|
526
|
4240 if (value[i].len == 1) {
|
|
4241 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
4242 "empty regex in server name \"%V\"", &value[i]);
|
|
4243 return NGX_CONF_ERROR;
|
|
4244 }
|
|
4245
|
326
|
4246 value[i].len--;
|
|
4247 value[i].data++;
|
|
4248
|
546
|
4249 ngx_memzero(&rc, sizeof(ngx_regex_compile_t));
|
|
4250
|
|
4251 rc.pattern = value[i];
|
|
4252 rc.err.len = NGX_MAX_CONF_ERRSTR;
|
|
4253 rc.err.data = errstr;
|
|
4254
|
554
|
4255 for (p = value[i].data; p < value[i].data + value[i].len; p++) {
|
|
4256 if (*p >= 'A' && *p <= 'Z') {
|
|
4257 rc.options = NGX_REGEX_CASELESS;
|
|
4258 break;
|
|
4259 }
|
|
4260 }
|
|
4261
|
546
|
4262 sn->regex = ngx_http_regex_compile(cf, &rc);
|
326
|
4263 if (sn->regex == NULL) {
|
|
4264 return NGX_CONF_ERROR;
|
|
4265 }
|
|
4266
|
358
|
4267 sn->name = value[i];
|
546
|
4268 cscf->captures = (rc.captures > 0);
|
356
|
4269 }
|
326
|
4270 #else
|
|
4271 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
640
|
4272 "using regex \"%V\" "
|
326
|
4273 "requires PCRE library", &value[i]);
|
|
4274
|
|
4275 return NGX_CONF_ERROR;
|
|
4276 #endif
|
0
|
4277 }
|
|
4278
|
|
4279 return NGX_CONF_OK;
|
|
4280 }
|
|
4281
|
|
4282
|
36
|
4283 static char *
|
|
4284 ngx_http_core_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
0
|
4285 {
|
546
|
4286 ngx_http_core_loc_conf_t *clcf = conf;
|
0
|
4287
|
144
|
4288 ngx_str_t *value;
|
574
|
4289 ngx_int_t alias;
|
|
4290 ngx_uint_t n;
|
144
|
4291 ngx_http_script_compile_t sc;
|
0
|
4292
|
|
4293 alias = (cmd->name.len == sizeof("alias") - 1) ? 1 : 0;
|
|
4294
|
546
|
4295 if (clcf->root.data) {
|
0
|
4296
|
574
|
4297 if ((clcf->alias != 0) == alias) {
|
0
|
4298 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
10
|
4299 "\"%V\" directive is duplicate",
|
|
4300 &cmd->name);
|
0
|
4301 } else {
|
|
4302 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
10
|
4303 "\"%V\" directive is duplicate, "
|
640
|
4304 "\"%s\" directive was specified earlier",
|
546
|
4305 &cmd->name, clcf->alias ? "alias" : "root");
|
0
|
4306 }
|
|
4307
|
|
4308 return NGX_CONF_ERROR;
|
|
4309 }
|
|
4310
|
546
|
4311 if (clcf->named && alias) {
|
324
|
4312 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
640
|
4313 "the \"alias\" directive cannot be used "
|
|
4314 "inside the named location");
|
324
|
4315
|
|
4316 return NGX_CONF_ERROR;
|
|
4317 }
|
|
4318
|
0
|
4319 value = cf->args->elts;
|
|
4320
|
294
|
4321 if (ngx_strstr(value[1].data, "$document_root")
|
|
4322 || ngx_strstr(value[1].data, "${document_root}"))
|
|
4323 {
|
|
4324 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
640
|
4325 "the $document_root variable cannot be used "
|
294
|
4326 "in the \"%V\" directive",
|
|
4327 &cmd->name);
|
|
4328
|
|
4329 return NGX_CONF_ERROR;
|
|
4330 }
|
|
4331
|
412
|
4332 if (ngx_strstr(value[1].data, "$realpath_root")
|
|
4333 || ngx_strstr(value[1].data, "${realpath_root}"))
|
|
4334 {
|
|
4335 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
640
|
4336 "the $realpath_root variable cannot be used "
|
412
|
4337 "in the \"%V\" directive",
|
|
4338 &cmd->name);
|
|
4339
|
|
4340 return NGX_CONF_ERROR;
|
|
4341 }
|
|
4342
|
574
|
4343 clcf->alias = alias ? clcf->name.len : 0;
|
546
|
4344 clcf->root = value[1];
|
|
4345
|
|
4346 if (!alias && clcf->root.data[clcf->root.len - 1] == '/') {
|
|
4347 clcf->root.len--;
|
0
|
4348 }
|
|
4349
|
546
|
4350 if (clcf->root.data[0] != '$') {
|
|
4351 if (ngx_conf_full_name(cf->cycle, &clcf->root, 0) != NGX_OK) {
|
216
|
4352 return NGX_CONF_ERROR;
|
|
4353 }
|
152
|
4354 }
|
|
4355
|
546
|
4356 n = ngx_http_script_variables_count(&clcf->root);
|
144
|
4357
|
456
|
4358 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
|
596
|
4359 sc.variables = n;
|
|
4360
|
|
4361 #if (NGX_PCRE)
|
|
4362 if (alias && clcf->regex) {
|
|
4363 n = 1;
|
|
4364 }
|
|
4365 #endif
|
456
|
4366
|
|
4367 if (n) {
|
|
4368 sc.cf = cf;
|
546
|
4369 sc.source = &clcf->root;
|
|
4370 sc.lengths = &clcf->root_lengths;
|
|
4371 sc.values = &clcf->root_values;
|
456
|
4372 sc.complete_lengths = 1;
|
|
4373 sc.complete_values = 1;
|
|
4374
|
|
4375 if (ngx_http_script_compile(&sc) != NGX_OK) {
|
|
4376 return NGX_CONF_ERROR;
|
|
4377 }
|
144
|
4378 }
|
|
4379
|
0
|
4380 return NGX_CONF_OK;
|
|
4381 }
|
|
4382
|
|
4383
|
180
|
4384 static ngx_http_method_name_t ngx_methods_names[] = {
|
286
|
4385 { (u_char *) "GET", (uint32_t) ~NGX_HTTP_GET },
|
|
4386 { (u_char *) "HEAD", (uint32_t) ~NGX_HTTP_HEAD },
|
|
4387 { (u_char *) "POST", (uint32_t) ~NGX_HTTP_POST },
|
|
4388 { (u_char *) "PUT", (uint32_t) ~NGX_HTTP_PUT },
|
|
4389 { (u_char *) "DELETE", (uint32_t) ~NGX_HTTP_DELETE },
|
|
4390 { (u_char *) "MKCOL", (uint32_t) ~NGX_HTTP_MKCOL },
|
|
4391 { (u_char *) "COPY", (uint32_t) ~NGX_HTTP_COPY },
|
|
4392 { (u_char *) "MOVE", (uint32_t) ~NGX_HTTP_MOVE },
|
|
4393 { (u_char *) "OPTIONS", (uint32_t) ~NGX_HTTP_OPTIONS },
|
|
4394 { (u_char *) "PROPFIND" , (uint32_t) ~NGX_HTTP_PROPFIND },
|
|
4395 { (u_char *) "PROPPATCH", (uint32_t) ~NGX_HTTP_PROPPATCH },
|
|
4396 { (u_char *) "LOCK", (uint32_t) ~NGX_HTTP_LOCK },
|
|
4397 { (u_char *) "UNLOCK", (uint32_t) ~NGX_HTTP_UNLOCK },
|
578
|
4398 { (u_char *) "PATCH", (uint32_t) ~NGX_HTTP_PATCH },
|
180
|
4399 { NULL, 0 }
|
|
4400 };
|
|
4401
|
|
4402
|
|
4403 static char *
|
|
4404 ngx_http_core_limit_except(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
4405 {
|
378
|
4406 ngx_http_core_loc_conf_t *pclcf = conf;
|
180
|
4407
|
|
4408 char *rv;
|
|
4409 void *mconf;
|
|
4410 ngx_str_t *value;
|
|
4411 ngx_uint_t i;
|
|
4412 ngx_conf_t save;
|
|
4413 ngx_http_module_t *module;
|
|
4414 ngx_http_conf_ctx_t *ctx, *pctx;
|
|
4415 ngx_http_method_name_t *name;
|
378
|
4416 ngx_http_core_loc_conf_t *clcf;
|
|
4417
|
|
4418 if (pclcf->limit_except) {
|
180
|
4419 return "duplicate";
|
|
4420 }
|
|
4421
|
378
|
4422 pclcf->limit_except = 0xffffffff;
|
180
|
4423
|
|
4424 value = cf->args->elts;
|
|
4425
|
|
4426 for (i = 1; i < cf->args->nelts; i++) {
|
|
4427 for (name = ngx_methods_names; name->name; name++) {
|
|
4428
|
|
4429 if (ngx_strcasecmp(value[i].data, name->name) == 0) {
|
378
|
4430 pclcf->limit_except &= name->method;
|
180
|
4431 goto next;
|
|
4432 }
|
|
4433 }
|
|
4434
|
|
4435 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
4436 "invalid method \"%V\"", &value[i]);
|
|
4437 return NGX_CONF_ERROR;
|
|
4438
|
|
4439 next:
|
|
4440 continue;
|
|
4441 }
|
|
4442
|
378
|
4443 if (!(pclcf->limit_except & NGX_HTTP_GET)) {
|
|
4444 pclcf->limit_except &= (uint32_t) ~NGX_HTTP_HEAD;
|
180
|
4445 }
|
|
4446
|
|
4447 ctx = ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t));
|
|
4448 if (ctx == NULL) {
|
|
4449 return NGX_CONF_ERROR;
|
|
4450 }
|
|
4451
|
|
4452 pctx = cf->ctx;
|
|
4453 ctx->main_conf = pctx->main_conf;
|
|
4454 ctx->srv_conf = pctx->srv_conf;
|
|
4455
|
|
4456 ctx->loc_conf = ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module);
|
|
4457 if (ctx->loc_conf == NULL) {
|
|
4458 return NGX_CONF_ERROR;
|
|
4459 }
|
|
4460
|
|
4461 for (i = 0; ngx_modules[i]; i++) {
|
|
4462 if (ngx_modules[i]->type != NGX_HTTP_MODULE) {
|
|
4463 continue;
|
|
4464 }
|
|
4465
|
|
4466 module = ngx_modules[i]->ctx;
|
|
4467
|
|
4468 if (module->create_loc_conf) {
|
|
4469
|
|
4470 mconf = module->create_loc_conf(cf);
|
|
4471 if (mconf == NULL) {
|
|
4472 return NGX_CONF_ERROR;
|
|
4473 }
|
|
4474
|
|
4475 ctx->loc_conf[ngx_modules[i]->ctx_index] = mconf;
|
|
4476 }
|
|
4477 }
|
|
4478
|
|
4479
|
378
|
4480 clcf = ctx->loc_conf[ngx_http_core_module.ctx_index];
|
|
4481 pclcf->limit_except_loc_conf = ctx->loc_conf;
|
|
4482 clcf->loc_conf = ctx->loc_conf;
|
|
4483 clcf->name = pclcf->name;
|
|
4484 clcf->noname = 1;
|
592
|
4485 clcf->lmt_excpt = 1;
|
378
|
4486
|
|
4487 if (ngx_http_add_location(cf, &pclcf->locations, clcf) != NGX_OK) {
|
180
|
4488 return NGX_CONF_ERROR;
|
|
4489 }
|
|
4490
|
|
4491 save = *cf;
|
|
4492 cf->ctx = ctx;
|
|
4493 cf->cmd_type = NGX_HTTP_LMT_CONF;
|
|
4494
|
|
4495 rv = ngx_conf_parse(cf, NULL);
|
|
4496
|
|
4497 *cf = save;
|
|
4498
|
|
4499 return rv;
|
|
4500 }
|
|
4501
|
|
4502
|
36
|
4503 static char *
|
390
|
4504 ngx_http_core_directio(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
4505 {
|
|
4506 ngx_http_core_loc_conf_t *clcf = conf;
|
|
4507
|
|
4508 ngx_str_t *value;
|
|
4509
|
|
4510 if (clcf->directio != NGX_CONF_UNSET) {
|
|
4511 return "is duplicate";
|
|
4512 }
|
|
4513
|
|
4514 value = cf->args->elts;
|
|
4515
|
|
4516 if (ngx_strcmp(value[1].data, "off") == 0) {
|
416
|
4517 clcf->directio = NGX_OPEN_FILE_DIRECTIO_OFF;
|
390
|
4518 return NGX_CONF_OK;
|
|
4519 }
|
|
4520
|
|
4521 clcf->directio = ngx_parse_offset(&value[1]);
|
|
4522 if (clcf->directio == (off_t) NGX_ERROR) {
|
|
4523 return "invalid value";
|
|
4524 }
|
|
4525
|
|
4526 return NGX_CONF_OK;
|
|
4527 }
|
|
4528
|
|
4529
|
|
4530 static char *
|
36
|
4531 ngx_http_core_error_page(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
0
|
4532 {
|
546
|
4533 ngx_http_core_loc_conf_t *clcf = conf;
|
0
|
4534
|
464
|
4535 u_char *p;
|
|
4536 ngx_int_t overwrite;
|
|
4537 ngx_str_t *value, uri, args;
|
|
4538 ngx_uint_t i, n;
|
|
4539 ngx_http_err_page_t *err;
|
|
4540 ngx_http_complex_value_t cv;
|
|
4541 ngx_http_compile_complex_value_t ccv;
|
0
|
4542
|
546
|
4543 if (clcf->error_pages == NULL) {
|
|
4544 clcf->error_pages = ngx_array_create(cf->pool, 4,
|
|
4545 sizeof(ngx_http_err_page_t));
|
|
4546 if (clcf->error_pages == NULL) {
|
0
|
4547 return NGX_CONF_ERROR;
|
|
4548 }
|
|
4549 }
|
|
4550
|
|
4551 value = cf->args->elts;
|
|
4552
|
|
4553 i = cf->args->nelts - 2;
|
|
4554
|
|
4555 if (value[i].data[0] == '=') {
|
|
4556 if (i == 1) {
|
|
4557 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
10
|
4558 "invalid value \"%V\"", &value[i]);
|
0
|
4559 return NGX_CONF_ERROR;
|
|
4560 }
|
|
4561
|
104
|
4562 if (value[i].len > 1) {
|
|
4563 overwrite = ngx_atoi(&value[i].data[1], value[i].len - 1);
|
|
4564
|
|
4565 if (overwrite == NGX_ERROR) {
|
|
4566 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
4567 "invalid value \"%V\"", &value[i]);
|
|
4568 return NGX_CONF_ERROR;
|
|
4569 }
|
|
4570
|
|
4571 } else {
|
|
4572 overwrite = 0;
|
0
|
4573 }
|
|
4574
|
|
4575 n = 2;
|
|
4576
|
|
4577 } else {
|
104
|
4578 overwrite = -1;
|
0
|
4579 n = 1;
|
|
4580 }
|
|
4581
|
222
|
4582 uri = value[cf->args->nelts - 1];
|
464
|
4583
|
|
4584 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t));
|
|
4585
|
|
4586 ccv.cf = cf;
|
|
4587 ccv.value = &uri;
|
|
4588 ccv.complex_value = &cv;
|
|
4589
|
|
4590 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) {
|
|
4591 return NGX_CONF_ERROR;
|
|
4592 }
|
|
4593
|
570
|
4594 ngx_str_null(&args);
|
464
|
4595
|
478
|
4596 if (cv.lengths == NULL && uri.data[0] == '/') {
|
464
|
4597 p = (u_char *) ngx_strchr(uri.data, '?');
|
|
4598
|
|
4599 if (p) {
|
|
4600 cv.value.len = p - uri.data;
|
|
4601 cv.value.data = uri.data;
|
|
4602 p++;
|
|
4603 args.len = (uri.data + uri.len) - p;
|
|
4604 args.data = p;
|
222
|
4605 }
|
|
4606 }
|
|
4607
|
0
|
4608 for (i = 1; i < cf->args->nelts - n; i++) {
|
546
|
4609 err = ngx_array_push(clcf->error_pages);
|
50
|
4610 if (err == NULL) {
|
0
|
4611 return NGX_CONF_ERROR;
|
|
4612 }
|
|
4613
|
|
4614 err->status = ngx_atoi(value[i].data, value[i].len);
|
36
|
4615
|
236
|
4616 if (err->status == NGX_ERROR || err->status == 499) {
|
0
|
4617 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
10
|
4618 "invalid value \"%V\"", &value[i]);
|
0
|
4619 return NGX_CONF_ERROR;
|
|
4620 }
|
|
4621
|
558
|
4622 if (err->status < 300 || err->status > 599) {
|
0
|
4623 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
558
|
4624 "value \"%V\" must be between 300 and 599",
|
10
|
4625 &value[i]);
|
0
|
4626 return NGX_CONF_ERROR;
|
|
4627 }
|
|
4628
|
602
|
4629 err->overwrite = overwrite;
|
|
4630
|
|
4631 if (overwrite == -1) {
|
366
|
4632 switch (err->status) {
|
|
4633 case NGX_HTTP_TO_HTTPS:
|
|
4634 case NGX_HTTPS_CERT_ERROR:
|
|
4635 case NGX_HTTPS_NO_CERT:
|
|
4636 err->overwrite = NGX_HTTP_BAD_REQUEST;
|
|
4637 default:
|
|
4638 break;
|
|
4639 }
|
|
4640 }
|
104
|
4641
|
464
|
4642 err->value = cv;
|
|
4643 err->args = args;
|
0
|
4644 }
|
|
4645
|
|
4646 return NGX_CONF_OK;
|
|
4647 }
|
|
4648
|
|
4649
|
36
|
4650 static char *
|
430
|
4651 ngx_http_core_try_files(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
4652 {
|
|
4653 ngx_http_core_loc_conf_t *clcf = conf;
|
|
4654
|
|
4655 ngx_str_t *value;
|
478
|
4656 ngx_int_t code;
|
430
|
4657 ngx_uint_t i, n;
|
|
4658 ngx_http_try_file_t *tf;
|
|
4659 ngx_http_script_compile_t sc;
|
|
4660 ngx_http_core_main_conf_t *cmcf;
|
|
4661
|
|
4662 if (clcf->try_files) {
|
|
4663 return "is duplicate";
|
|
4664 }
|
|
4665
|
|
4666 cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
|
|
4667
|
|
4668 cmcf->try_files = 1;
|
|
4669
|
|
4670 tf = ngx_pcalloc(cf->pool, cf->args->nelts * sizeof(ngx_http_try_file_t));
|
|
4671 if (tf == NULL) {
|
|
4672 return NGX_CONF_ERROR;
|
|
4673 }
|
|
4674
|
|
4675 clcf->try_files = tf;
|
|
4676
|
|
4677 value = cf->args->elts;
|
|
4678
|
|
4679 for (i = 0; i < cf->args->nelts - 1; i++) {
|
|
4680
|
|
4681 tf[i].name = value[i + 1];
|
|
4682
|
440
|
4683 if (tf[i].name.data[tf[i].name.len - 1] == '/') {
|
|
4684 tf[i].test_dir = 1;
|
|
4685 tf[i].name.len--;
|
464
|
4686 tf[i].name.data[tf[i].name.len] = '\0';
|
440
|
4687 }
|
|
4688
|
430
|
4689 n = ngx_http_script_variables_count(&tf[i].name);
|
|
4690
|
|
4691 if (n) {
|
|
4692 ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
|
|
4693
|
|
4694 sc.cf = cf;
|
|
4695 sc.source = &tf[i].name;
|
|
4696 sc.lengths = &tf[i].lengths;
|
|
4697 sc.values = &tf[i].values;
|
|
4698 sc.variables = n;
|
|
4699 sc.complete_lengths = 1;
|
|
4700 sc.complete_values = 1;
|
|
4701
|
|
4702 if (ngx_http_script_compile(&sc) != NGX_OK) {
|
|
4703 return NGX_CONF_ERROR;
|
|
4704 }
|
|
4705
|
|
4706 } else {
|
|
4707 /* add trailing '\0' to length */
|
|
4708 tf[i].name.len++;
|
|
4709 }
|
|
4710 }
|
|
4711
|
478
|
4712 if (tf[i - 1].name.data[0] == '=') {
|
|
4713
|
|
4714 code = ngx_atoi(tf[i - 1].name.data + 1, tf[i - 1].name.len - 2);
|
|
4715
|
676
|
4716 if (code == NGX_ERROR || code > 999) {
|
478
|
4717 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
4718 "invalid code \"%*s\"",
|
|
4719 tf[i - 1].name.len - 1, tf[i - 1].name.data);
|
|
4720 return NGX_CONF_ERROR;
|
|
4721 }
|
|
4722
|
|
4723 tf[i].code = code;
|
|
4724 }
|
|
4725
|
430
|
4726 return NGX_CONF_OK;
|
|
4727 }
|
|
4728
|
|
4729
|
|
4730 static char *
|
332
|
4731 ngx_http_core_open_file_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
4732 {
|
546
|
4733 ngx_http_core_loc_conf_t *clcf = conf;
|
332
|
4734
|
|
4735 time_t inactive;
|
|
4736 ngx_str_t *value, s;
|
|
4737 ngx_int_t max;
|
|
4738 ngx_uint_t i;
|
|
4739
|
546
|
4740 if (clcf->open_file_cache != NGX_CONF_UNSET_PTR) {
|
332
|
4741 return "is duplicate";
|
|
4742 }
|
|
4743
|
|
4744 value = cf->args->elts;
|
|
4745
|
|
4746 max = 0;
|
|
4747 inactive = 60;
|
|
4748
|
|
4749 for (i = 1; i < cf->args->nelts; i++) {
|
|
4750
|
|
4751 if (ngx_strncmp(value[i].data, "max=", 4) == 0) {
|
|
4752
|
|
4753 max = ngx_atoi(value[i].data + 4, value[i].len - 4);
|
648
|
4754 if (max <= 0) {
|
388
|
4755 goto failed;
|
332
|
4756 }
|
|
4757
|
|
4758 continue;
|
|
4759 }
|
|
4760
|
|
4761 if (ngx_strncmp(value[i].data, "inactive=", 9) == 0) {
|
|
4762
|
|
4763 s.len = value[i].len - 9;
|
|
4764 s.data = value[i].data + 9;
|
|
4765
|
|
4766 inactive = ngx_parse_time(&s, 1);
|
662
|
4767 if (inactive == (time_t) NGX_ERROR) {
|
388
|
4768 goto failed;
|
332
|
4769 }
|
|
4770
|
|
4771 continue;
|
|
4772 }
|
|
4773
|
|
4774 if (ngx_strcmp(value[i].data, "off") == 0) {
|
|
4775
|
546
|
4776 clcf->open_file_cache = NULL;
|
332
|
4777
|
|
4778 continue;
|
|
4779 }
|
|
4780
|
388
|
4781 failed:
|
|
4782
|
332
|
4783 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
4784 "invalid \"open_file_cache\" parameter \"%V\"",
|
|
4785 &value[i]);
|
|
4786 return NGX_CONF_ERROR;
|
|
4787 }
|
|
4788
|
546
|
4789 if (clcf->open_file_cache == NULL) {
|
332
|
4790 return NGX_CONF_OK;
|
|
4791 }
|
|
4792
|
|
4793 if (max == 0) {
|
|
4794 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
666
|
4795 "\"open_file_cache\" must have the \"max\" parameter");
|
332
|
4796 return NGX_CONF_ERROR;
|
|
4797 }
|
|
4798
|
546
|
4799 clcf->open_file_cache = ngx_open_file_cache_init(cf->pool, max, inactive);
|
|
4800 if (clcf->open_file_cache) {
|
332
|
4801 return NGX_CONF_OK;
|
|
4802 }
|
|
4803
|
|
4804 return NGX_CONF_ERROR;
|
|
4805 }
|
|
4806
|
|
4807
|
|
4808 static char *
|
58
|
4809 ngx_http_core_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
4810 {
|
546
|
4811 ngx_http_core_loc_conf_t *clcf = conf;
|
58
|
4812
|
668
|
4813 ngx_str_t *value, name;
|
482
|
4814
|
546
|
4815 if (clcf->error_log) {
|
484
|
4816 return "is duplicate";
|
|
4817 }
|
|
4818
|
482
|
4819 value = cf->args->elts;
|
|
4820
|
668
|
4821 if (ngx_strcmp(value[1].data, "stderr") == 0) {
|
|
4822 ngx_str_null(&name);
|
|
4823
|
|
4824 } else {
|
|
4825 name = value[1];
|
|
4826 }
|
|
4827
|
|
4828 clcf->error_log = ngx_log_create(cf->cycle, &name);
|
546
|
4829 if (clcf->error_log == NULL) {
|
58
|
4830 return NGX_CONF_ERROR;
|
|
4831 }
|
|
4832
|
484
|
4833 if (cf->args->nelts == 2) {
|
546
|
4834 clcf->error_log->log_level = NGX_LOG_ERR;
|
484
|
4835 return NGX_CONF_OK;
|
|
4836 }
|
|
4837
|
546
|
4838 return ngx_log_set_levels(cf, clcf->error_log);
|
58
|
4839 }
|
|
4840
|
|
4841
|
|
4842 static char *
|
36
|
4843 ngx_http_core_keepalive(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
0
|
4844 {
|
546
|
4845 ngx_http_core_loc_conf_t *clcf = conf;
|
0
|
4846
|
|
4847 ngx_str_t *value;
|
|
4848
|
546
|
4849 if (clcf->keepalive_timeout != NGX_CONF_UNSET_MSEC) {
|
0
|
4850 return "is duplicate";
|
|
4851 }
|
|
4852
|
|
4853 value = cf->args->elts;
|
|
4854
|
546
|
4855 clcf->keepalive_timeout = ngx_parse_time(&value[1], 0);
|
|
4856
|
|
4857 if (clcf->keepalive_timeout == (ngx_msec_t) NGX_ERROR) {
|
0
|
4858 return "invalid value";
|
|
4859 }
|
|
4860
|
|
4861 if (cf->args->nelts == 2) {
|
|
4862 return NGX_CONF_OK;
|
|
4863 }
|
|
4864
|
546
|
4865 clcf->keepalive_header = ngx_parse_time(&value[2], 1);
|
|
4866
|
662
|
4867 if (clcf->keepalive_header == (time_t) NGX_ERROR) {
|
0
|
4868 return "invalid value";
|
|
4869 }
|
|
4870
|
|
4871 return NGX_CONF_OK;
|
|
4872 }
|
|
4873
|
|
4874
|
36
|
4875 static char *
|
58
|
4876 ngx_http_core_internal(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
0
|
4877 {
|
546
|
4878 ngx_http_core_loc_conf_t *clcf = conf;
|
|
4879
|
|
4880 if (clcf->internal != NGX_CONF_UNSET) {
|
58
|
4881 return "is duplicate";
|
0
|
4882 }
|
|
4883
|
546
|
4884 clcf->internal = 1;
|
58
|
4885
|
|
4886 return NGX_CONF_OK;
|
0
|
4887 }
|
|
4888
|
|
4889
|
36
|
4890 static char *
|
348
|
4891 ngx_http_core_resolver(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
4892 {
|
|
4893 ngx_http_core_loc_conf_t *clcf = conf;
|
|
4894
|
|
4895 ngx_str_t *value;
|
|
4896
|
366
|
4897 if (clcf->resolver) {
|
|
4898 return "is duplicate";
|
|
4899 }
|
|
4900
|
348
|
4901 value = cf->args->elts;
|
|
4902
|
646
|
4903 clcf->resolver = ngx_resolver_create(cf, &value[1], cf->args->nelts - 1);
|
|
4904 if (clcf->resolver == NULL) {
|
348
|
4905 return NGX_CONF_ERROR;
|
|
4906 }
|
|
4907
|
|
4908 return NGX_CONF_OK;
|
|
4909 }
|
|
4910
|
|
4911
|
358
|
4912 #if (NGX_HTTP_GZIP)
|
|
4913
|
|
4914 static char *
|
|
4915 ngx_http_gzip_disable(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
4916 {
|
400
|
4917 ngx_http_core_loc_conf_t *clcf = conf;
|
|
4918
|
358
|
4919 #if (NGX_PCRE)
|
|
4920
|
546
|
4921 ngx_str_t *value;
|
|
4922 ngx_uint_t i;
|
|
4923 ngx_regex_elt_t *re;
|
|
4924 ngx_regex_compile_t rc;
|
|
4925 u_char errstr[NGX_MAX_CONF_ERRSTR];
|
358
|
4926
|
|
4927 if (clcf->gzip_disable == NGX_CONF_UNSET_PTR) {
|
|
4928 clcf->gzip_disable = ngx_array_create(cf->pool, 2,
|
|
4929 sizeof(ngx_regex_elt_t));
|
|
4930 if (clcf->gzip_disable == NULL) {
|
|
4931 return NGX_CONF_ERROR;
|
|
4932 }
|
|
4933 }
|
|
4934
|
|
4935 value = cf->args->elts;
|
|
4936
|
546
|
4937 ngx_memzero(&rc, sizeof(ngx_regex_compile_t));
|
|
4938
|
|
4939 rc.pool = cf->pool;
|
|
4940 rc.err.len = NGX_MAX_CONF_ERRSTR;
|
|
4941 rc.err.data = errstr;
|
358
|
4942
|
|
4943 for (i = 1; i < cf->args->nelts; i++) {
|
|
4944
|
596
|
4945 if (ngx_strcmp(value[i].data, "msie6") == 0) {
|
400
|
4946 clcf->gzip_disable_msie6 = 1;
|
|
4947 continue;
|
|
4948 }
|
|
4949
|
602
|
4950 #if (NGX_HTTP_DEGRADATION)
|
|
4951
|
|
4952 if (ngx_strcmp(value[i].data, "degradation") == 0) {
|
|
4953 clcf->gzip_disable_degradation = 1;
|
|
4954 continue;
|
|
4955 }
|
|
4956
|
|
4957 #endif
|
|
4958
|
358
|
4959 re = ngx_array_push(clcf->gzip_disable);
|
|
4960 if (re == NULL) {
|
|
4961 return NGX_CONF_ERROR;
|
|
4962 }
|
|
4963
|
596
|
4964 rc.pattern = value[i];
|
546
|
4965 rc.options = NGX_REGEX_CASELESS;
|
|
4966
|
|
4967 if (ngx_regex_compile(&rc) != NGX_OK) {
|
|
4968 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "%V", &rc.err);
|
358
|
4969 return NGX_CONF_ERROR;
|
|
4970 }
|
|
4971
|
546
|
4972 re->regex = rc.regex;
|
358
|
4973 re->name = value[i].data;
|
|
4974 }
|
|
4975
|
|
4976 return NGX_CONF_OK;
|
|
4977
|
|
4978 #else
|
602
|
4979 ngx_str_t *value;
|
|
4980 ngx_uint_t i;
|
400
|
4981
|
|
4982 value = cf->args->elts;
|
|
4983
|
602
|
4984 for (i = 1; i < cf->args->nelts; i++) {
|
|
4985 if (ngx_strcmp(value[i].data, "msie6") == 0) {
|
|
4986 clcf->gzip_disable_msie6 = 1;
|
|
4987 continue;
|
|
4988 }
|
|
4989
|
|
4990 #if (NGX_HTTP_DEGRADATION)
|
|
4991
|
|
4992 if (ngx_strcmp(value[i].data, "degradation") == 0) {
|
|
4993 clcf->gzip_disable_degradation = 1;
|
|
4994 continue;
|
|
4995 }
|
|
4996
|
|
4997 #endif
|
|
4998
|
|
4999 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
5000 "without PCRE library \"gzip_disable\" supports "
|
|
5001 "builtin \"msie6\" and \"degradation\" mask only");
|
|
5002
|
|
5003 return NGX_CONF_ERROR;
|
400
|
5004 }
|
|
5005
|
602
|
5006 return NGX_CONF_OK;
|
|
5007
|
358
|
5008 #endif
|
|
5009 }
|
|
5010
|
|
5011 #endif
|
|
5012
|
|
5013
|
664
|
5014 #if (NGX_HAVE_OPENAT)
|
|
5015
|
|
5016 static char *
|
|
5017 ngx_http_disable_symlinks(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
5018 {
|
|
5019 ngx_http_core_loc_conf_t *clcf = conf;
|
|
5020
|
|
5021 ngx_str_t *value;
|
|
5022 ngx_uint_t i;
|
|
5023 ngx_http_compile_complex_value_t ccv;
|
|
5024
|
|
5025 if (clcf->disable_symlinks != NGX_CONF_UNSET_UINT) {
|
|
5026 return "is duplicate";
|
|
5027 }
|
|
5028
|
|
5029 value = cf->args->elts;
|
|
5030
|
|
5031 for (i = 1; i < cf->args->nelts; i++) {
|
|
5032
|
|
5033 if (ngx_strcmp(value[i].data, "off") == 0) {
|
|
5034 clcf->disable_symlinks = NGX_DISABLE_SYMLINKS_OFF;
|
|
5035 continue;
|
|
5036 }
|
|
5037
|
|
5038 if (ngx_strcmp(value[i].data, "if_not_owner") == 0) {
|
|
5039 clcf->disable_symlinks = NGX_DISABLE_SYMLINKS_NOTOWNER;
|
|
5040 continue;
|
|
5041 }
|
|
5042
|
|
5043 if (ngx_strcmp(value[i].data, "on") == 0) {
|
|
5044 clcf->disable_symlinks = NGX_DISABLE_SYMLINKS_ON;
|
|
5045 continue;
|
|
5046 }
|
|
5047
|
|
5048 if (ngx_strncmp(value[i].data, "from=", 5) == 0) {
|
|
5049 value[i].len -= 5;
|
|
5050 value[i].data += 5;
|
|
5051
|
|
5052 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t));
|
|
5053
|
|
5054 ccv.cf = cf;
|
|
5055 ccv.value = &value[i];
|
|
5056 ccv.complex_value = ngx_palloc(cf->pool,
|
|
5057 sizeof(ngx_http_complex_value_t));
|
|
5058 if (ccv.complex_value == NULL) {
|
|
5059 return NGX_CONF_ERROR;
|
|
5060 }
|
|
5061
|
|
5062 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) {
|
|
5063 return NGX_CONF_ERROR;
|
|
5064 }
|
|
5065
|
|
5066 clcf->disable_symlinks_from = ccv.complex_value;
|
|
5067
|
|
5068 continue;
|
|
5069 }
|
|
5070
|
|
5071 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
5072 "invalid parameter \"%V\"", &value[i]);
|
|
5073 return NGX_CONF_ERROR;
|
|
5074 }
|
|
5075
|
|
5076 if (clcf->disable_symlinks == NGX_CONF_UNSET_UINT) {
|
|
5077 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
5078 "\"%V\" must have \"off\", \"on\" "
|
|
5079 "or \"if_not_owner\" parameter",
|
|
5080 &cmd->name);
|
|
5081 return NGX_CONF_ERROR;
|
|
5082 }
|
|
5083
|
|
5084 if (cf->args->nelts == 2) {
|
|
5085 clcf->disable_symlinks_from = NULL;
|
|
5086 return NGX_CONF_OK;
|
|
5087 }
|
|
5088
|
|
5089 if (clcf->disable_symlinks_from == NGX_CONF_UNSET_PTR) {
|
|
5090 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
5091 "duplicate parameters \"%V %V\"",
|
|
5092 &value[1], &value[2]);
|
|
5093 return NGX_CONF_ERROR;
|
|
5094 }
|
|
5095
|
|
5096 if (clcf->disable_symlinks == NGX_DISABLE_SYMLINKS_OFF) {
|
|
5097 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
5098 "\"from=\" cannot be used with \"off\" parameter");
|
|
5099 return NGX_CONF_ERROR;
|
|
5100 }
|
|
5101
|
|
5102 return NGX_CONF_OK;
|
|
5103 }
|
|
5104
|
|
5105 #endif
|
|
5106
|
|
5107
|
348
|
5108 static char *
|
36
|
5109 ngx_http_core_lowat_check(ngx_conf_t *cf, void *post, void *data)
|
0
|
5110 {
|
22
|
5111 #if (NGX_FREEBSD)
|
2
|
5112 ssize_t *np = data;
|
0
|
5113
|
222
|
5114 if ((u_long) *np >= ngx_freebsd_net_inet_tcp_sendspace) {
|
0
|
5115 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
5116 "\"send_lowat\" must be less than %d "
|
|
5117 "(sysctl net.inet.tcp.sendspace)",
|
|
5118 ngx_freebsd_net_inet_tcp_sendspace);
|
|
5119
|
|
5120 return NGX_CONF_ERROR;
|
|
5121 }
|
|
5122
|
18
|
5123 #elif !(NGX_HAVE_SO_SNDLOWAT)
|
22
|
5124 ssize_t *np = data;
|
0
|
5125
|
|
5126 ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
|
|
5127 "\"send_lowat\" is not supported, ignored");
|
|
5128
|
2
|
5129 *np = 0;
|
|
5130
|
0
|
5131 #endif
|
|
5132
|
|
5133 return NGX_CONF_OK;
|
|
5134 }
|
300
|
5135
|
|
5136
|
|
5137 static char *
|
|
5138 ngx_http_core_pool_size(ngx_conf_t *cf, void *post, void *data)
|
|
5139 {
|
|
5140 size_t *sp = data;
|
|
5141
|
|
5142 if (*sp < NGX_MIN_POOL_SIZE) {
|
|
5143 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
558
|
5144 "the pool size must be no less than %uz",
|
|
5145 NGX_MIN_POOL_SIZE);
|
|
5146 return NGX_CONF_ERROR;
|
|
5147 }
|
|
5148
|
|
5149 if (*sp % NGX_POOL_ALIGNMENT) {
|
|
5150 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
|
5151 "the pool size must be a multiple of %uz",
|
|
5152 NGX_POOL_ALIGNMENT);
|
300
|
5153 return NGX_CONF_ERROR;
|
|
5154 }
|
|
5155
|
|
5156 return NGX_CONF_OK;
|
|
5157 }
|