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