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