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