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