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