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