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