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