Mercurial > hg > nginx
comparison src/http/ngx_http_core_module.c @ 4472:c95b828912a3
Core: protection from cycles with named locations and post_action.
Now redirects to named locations are counted against normal uri changes
limit, and post_action respects this limit as well. As a result at least
the following (bad) configurations no longer trigger infinite cycles:
1. Post action which recursively triggers post action:
location / {
post_action /index.html;
}
2. Post action pointing to nonexistent named location:
location / {
post_action @nonexistent;
}
3. Recursive error page for 500 (Internal Server Error) pointing to
a nonexistent named location:
location / {
recursive_error_pages on;
error_page 500 @nonexistent;
return 500;
}
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 13 Feb 2012 15:35:48 +0000 |
parents | b19a651471d9 |
children | 41f640a693de |
comparison
equal
deleted
inserted
replaced
4471:b19a651471d9 | 4472:c95b828912a3 |
---|---|
2522 ngx_http_core_srv_conf_t *cscf; | 2522 ngx_http_core_srv_conf_t *cscf; |
2523 ngx_http_core_loc_conf_t **clcfp; | 2523 ngx_http_core_loc_conf_t **clcfp; |
2524 ngx_http_core_main_conf_t *cmcf; | 2524 ngx_http_core_main_conf_t *cmcf; |
2525 | 2525 |
2526 r->main->count++; | 2526 r->main->count++; |
2527 r->uri_changes--; | |
2528 | |
2529 if (r->uri_changes == 0) { | |
2530 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
2531 "rewrite or internal redirection cycle " | |
2532 "while redirect to named location \"%V\"", name); | |
2533 | |
2534 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); | |
2535 return NGX_DONE; | |
2536 } | |
2527 | 2537 |
2528 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); | 2538 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
2529 | 2539 |
2530 if (cscf->named_locations) { | 2540 if (cscf->named_locations) { |
2531 | 2541 |