Mercurial > hg > nginx-vendor-0-7
comparison src/http/modules/ngx_http_rewrite_module.c @ 122:d25a1d6034f1 NGINX_0_3_8
nginx 0.3.8
*) Security: nginx now checks URI got from a backend in
"X-Accel-Redirect" header line or in SSI file for the "/../" paths
and zeroes.
*) Change: nginx now does not treat the empty user name in the
"Authorization" header line as valid one.
*) Feature: the "ssl_session_timeout" directives of the
ngx_http_ssl_module and ngx_imap_ssl_module.
*) Feature: the "auth_http_header" directive of the
ngx_imap_auth_http_module.
*) Feature: the "add_header" directive.
*) Feature: the ngx_http_realip_module.
*) Feature: the new variables to use in the "log_format" directive:
$bytes_sent, $apache_bytes_sent, $status, $time_gmt, $uri,
$request_time, $request_length, $upstream_status,
$upstream_response_time, $gzip_ratio, $uid_got, $uid_set,
$connection, $pipe, and $msec. The parameters in the "%name" form
will be canceled soon.
*) Change: now the false variable values in the "if" directive are the
empty string "" and string starting with "0".
*) Bugfix: while using proxied or FastCGI-server nginx may leave
connections and temporary files with client requests in open state.
*) Bugfix: the worker processes did not flush the buffered logs on
graceful exit.
*) Bugfix: if the request URI was changes by the "rewrite" directive
and the request was proxied in location given by regular expression,
then the incorrect request was transferred to backend; bug appeared
in 0.2.6.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" header.
*) Bugfix: nginx may stop to accept requests if the "rtsig" method and
several worker processes were used.
*) Bugfix: the "\"" and "\'" escape symbols were incorrectly handled in
SSI commands.
*) Bugfix: if the response was ended just after the SSI command and
gzipping was used, then the response did not transferred complete or
did not transferred at all.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Wed, 09 Nov 2005 00:00:00 +0300 |
parents | 146eff53ab60 |
children | df17fbafec8f |
comparison
equal
deleted
inserted
replaced
121:737953b238a4 | 122:d25a1d6034f1 |
---|---|
140 NGX_MODULE_V1_PADDING | 140 NGX_MODULE_V1_PADDING |
141 }; | 141 }; |
142 | 142 |
143 | 143 |
144 static ngx_http_variable_value_t ngx_http_rewrite_null_value = | 144 static ngx_http_variable_value_t ngx_http_rewrite_null_value = |
145 { 0, ngx_string("") }; | 145 ngx_http_variable(""); |
146 | 146 |
147 | 147 |
148 static ngx_int_t | 148 static ngx_int_t |
149 ngx_http_rewrite_handler(ngx_http_request_t *r) | 149 ngx_http_rewrite_handler(ngx_http_request_t *r) |
150 { | 150 { |
212 cf = ngx_http_get_module_loc_conf(r, ngx_http_rewrite_module); | 212 cf = ngx_http_get_module_loc_conf(r, ngx_http_rewrite_module); |
213 | 213 |
214 e->ip += sizeof(uintptr_t); | 214 e->ip += sizeof(uintptr_t); |
215 | 215 |
216 if (cf->referers == NULL) { | 216 if (cf->referers == NULL) { |
217 e->sp->value = 0; | 217 e->sp->data = (u_char *) ""; |
218 e->sp->text.len = 0; | 218 e->sp->len = 0; |
219 e->sp->text.data = (u_char *) ""; | |
220 e->sp++; | 219 e->sp++; |
221 | 220 |
222 return; | 221 return; |
223 } | 222 } |
224 | 223 |
225 if (r->headers_in.referer == NULL) { | 224 if (r->headers_in.referer == NULL) { |
226 if (cf->no_referer) { | 225 if (cf->no_referer) { |
227 e->sp->value = 0; | 226 e->sp->data = (u_char *) ""; |
228 e->sp->text.len = 0; | 227 e->sp->len = 0; |
229 e->sp->text.data = (u_char *) ""; | |
230 e->sp++; | 228 e->sp++; |
231 | 229 |
232 return; | 230 return; |
233 | 231 |
234 } else { | 232 } else { |
235 e->sp->value = 1; | 233 e->sp->data = (u_char *) "1"; |
236 e->sp->text.len = 1; | 234 e->sp->len = 1; |
237 e->sp->text.data = (u_char *) "1"; | |
238 e->sp++; | 235 e->sp++; |
239 | 236 |
240 return; | 237 return; |
241 } | 238 } |
242 } | 239 } |
246 | 243 |
247 if (len < sizeof("http://i.ru") - 1 | 244 if (len < sizeof("http://i.ru") - 1 |
248 || (ngx_strncasecmp(ref, "http://", 7) != 0)) | 245 || (ngx_strncasecmp(ref, "http://", 7) != 0)) |
249 { | 246 { |
250 if (cf->blocked_referer) { | 247 if (cf->blocked_referer) { |
251 e->sp->value = 0; | 248 e->sp->data = (u_char *) ""; |
252 e->sp->text.len = 0; | 249 e->sp->len = 0; |
253 e->sp->text.data = (u_char *) "0"; | |
254 e->sp++; | 250 e->sp++; |
255 | 251 |
256 return; | 252 return; |
257 | 253 |
258 } else { | 254 } else { |
259 e->sp->value = 1; | 255 e->sp->data = (u_char *) "1"; |
260 e->sp->text.len = 1; | 256 e->sp->len = 1; |
261 e->sp->text.data = (u_char *) "1"; | |
262 e->sp++; | 257 e->sp++; |
263 | 258 |
264 return; | 259 return; |
265 } | 260 } |
266 } | 261 } |
286 } | 281 } |
287 | 282 |
288 if (ngx_strncmp(&ref[n], refs[i].name.data, | 283 if (ngx_strncmp(&ref[n], refs[i].name.data, |
289 refs[i].name.len) == 0) | 284 refs[i].name.len) == 0) |
290 { | 285 { |
291 e->sp->value = 0; | 286 e->sp->data = (u_char *) ""; |
292 e->sp->text.len = 0; | 287 e->sp->len = 0; |
293 e->sp->text.data = (u_char *) ""; | |
294 e->sp++; | 288 e->sp++; |
295 | 289 |
296 return; | 290 return; |
297 } | 291 } |
298 } | 292 } |
299 | 293 |
300 } else { | 294 } else { |
301 if (ngx_strncasecmp(refs[i].name.data, ref, refs[i].name.len) == 0) | 295 if (ngx_strncasecmp(refs[i].name.data, ref, refs[i].name.len) == 0) |
302 { | 296 { |
303 e->sp->value = 0; | 297 e->sp->data = (u_char *) ""; |
304 e->sp->text.len = 0; | 298 e->sp->len = 0; |
305 e->sp->text.data = (u_char *) ""; | |
306 e->sp++; | 299 e->sp++; |
307 | 300 |
308 return; | 301 return; |
309 } | 302 } |
310 } | 303 } |
311 } | 304 } |
312 | 305 |
313 e->sp->value = 1; | 306 e->sp->data = (u_char *) "1"; |
314 e->sp->text.len = 1; | 307 e->sp->len = 1; |
315 e->sp->text.data = (u_char *) "1"; | |
316 e->sp++; | 308 e->sp++; |
317 } | 309 } |
318 | 310 |
319 | 311 |
320 static ngx_http_variable_value_t * | 312 static ngx_int_t |
321 ngx_http_rewrite_var(ngx_http_request_t *r, uintptr_t data) | 313 ngx_http_rewrite_var(ngx_http_request_t *r, ngx_http_variable_value_t *v, |
314 uintptr_t data) | |
322 { | 315 { |
323 ngx_http_variable_t *var; | 316 ngx_http_variable_t *var; |
324 ngx_http_core_main_conf_t *cmcf; | 317 ngx_http_core_main_conf_t *cmcf; |
325 | 318 |
326 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); | 319 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); |
334 */ | 327 */ |
335 | 328 |
336 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, | 329 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, |
337 "using uninitialized \"%V\" variable", &var[data].name); | 330 "using uninitialized \"%V\" variable", &var[data].name); |
338 | 331 |
339 return &ngx_http_rewrite_null_value; | 332 *v = ngx_http_rewrite_null_value; |
333 | |
334 return NGX_OK; | |
340 } | 335 } |
341 | 336 |
342 | 337 |
343 static void * | 338 static void * |
344 ngx_http_rewrite_create_loc_conf(ngx_conf_t *cf) | 339 ngx_http_rewrite_create_loc_conf(ngx_conf_t *cf) |
408 { | 403 { |
409 ngx_http_handler_pt *h; | 404 ngx_http_handler_pt *h; |
410 ngx_http_core_main_conf_t *cmcf; | 405 ngx_http_core_main_conf_t *cmcf; |
411 | 406 |
412 cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module); | 407 cmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_core_module); |
408 | |
409 h = ngx_array_push(&cmcf->phases[NGX_HTTP_SERVER_REWRITE_PHASE].handlers); | |
410 if (h == NULL) { | |
411 return NGX_ERROR; | |
412 } | |
413 | |
414 *h = ngx_http_rewrite_handler; | |
413 | 415 |
414 h = ngx_array_push(&cmcf->phases[NGX_HTTP_REWRITE_PHASE].handlers); | 416 h = ngx_array_push(&cmcf->phases[NGX_HTTP_REWRITE_PHASE].handlers); |
415 if (h == NULL) { | 417 if (h == NULL) { |
416 return NGX_ERROR; | 418 return NGX_ERROR; |
417 } | 419 } |