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