comparison src/http/ngx_http_core_module.c @ 674:4dcaf40cc702 NGINX_1_3_0

nginx 1.3.0 *) Feature: the "debug_connection" directive now supports IPv6 addresses and the "unix:" parameter. *) Feature: the "set_real_ip_from" directive and the "proxy" parameter of the "geo" directive now support IPv6 addresses. *) Feature: the "real_ip_recursive", "geoip_proxy", and "geoip_proxy_recursive" directives. *) Feature: the "proxy_recursive" parameter of the "geo" directive. *) Bugfix: a segmentation fault might occur in a worker process if the "resolver" directive was used. *) Bugfix: a segmentation fault might occur in a worker process if the "fastcgi_pass", "scgi_pass", or "uwsgi_pass" directives were used and backend returned incorrect response. *) Bugfix: a segmentation fault might occur in a worker process if the "rewrite" directive was used and new request arguments in a replacement used variables. *) Bugfix: nginx might hog CPU if the open file resource limit was reached. *) Bugfix: nginx might loop infinitely over backends if the "proxy_next_upstream" directive with the "http_404" parameter was used and there were backup servers specified in an upstream block. *) Bugfix: adding the "down" parameter of the "server" directive might cause unneeded client redistribution among backend servers if the "ip_hash" directive was used. *) Bugfix: socket leak. Thanks to Yichun Zhang. *) Bugfix: in the ngx_http_fastcgi_module.
author Igor Sysoev <http://sysoev.ru>
date Tue, 15 May 2012 00:00:00 +0400
parents f41d4b305d22
children bfa81a0490a2
comparison
equal deleted inserted replaced
673:1e5c7a976f48 674:4dcaf40cc702
2597 2597
2598 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); 2598 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
2599 2599
2600 r->phase_handler = cmcf->phase_engine.location_rewrite_index; 2600 r->phase_handler = cmcf->phase_engine.location_rewrite_index;
2601 2601
2602 r->write_event_handler = ngx_http_core_run_phases;
2602 ngx_http_core_run_phases(r); 2603 ngx_http_core_run_phases(r);
2603 2604
2604 return NGX_DONE; 2605 return NGX_DONE;
2605 } 2606 }
2606 } 2607 }
2693 of->disable_symlinks_from = from.len - 1; 2694 of->disable_symlinks_from = from.len - 1;
2694 } 2695 }
2695 #endif 2696 #endif
2696 2697
2697 return NGX_OK; 2698 return NGX_OK;
2699 }
2700
2701
2702 ngx_int_t
2703 ngx_http_get_forwarded_addr(ngx_http_request_t *r, ngx_addr_t *addr,
2704 u_char *xff, size_t xfflen, ngx_array_t *proxies, int recursive)
2705 {
2706 u_char *p;
2707 in_addr_t inaddr;
2708 ngx_addr_t paddr;
2709 ngx_cidr_t *cidr;
2710 ngx_uint_t family, i;
2711 #if (NGX_HAVE_INET6)
2712 ngx_uint_t n;
2713 struct in6_addr *inaddr6;
2714 #endif
2715
2716 #if (NGX_SUPPRESS_WARN)
2717 inaddr = 0;
2718 #if (NGX_HAVE_INET6)
2719 inaddr6 = NULL;
2720 #endif
2721 #endif
2722
2723 family = addr->sockaddr->sa_family;
2724
2725 if (family == AF_INET) {
2726 inaddr = ((struct sockaddr_in *) addr->sockaddr)->sin_addr.s_addr;
2727 }
2728
2729 #if (NGX_HAVE_INET6)
2730 else if (family == AF_INET6) {
2731 inaddr6 = &((struct sockaddr_in6 *) addr->sockaddr)->sin6_addr;
2732
2733 if (IN6_IS_ADDR_V4MAPPED(inaddr6)) {
2734 family = AF_INET;
2735 inaddr = *(in_addr_t *) &inaddr6->s6_addr[12];
2736 }
2737 }
2738 #endif
2739
2740 for (cidr = proxies->elts, i = 0; i < proxies->nelts; i++) {
2741 if (cidr[i].family != family) {
2742 goto next;
2743 }
2744
2745 switch (family) {
2746
2747 #if (NGX_HAVE_INET6)
2748 case AF_INET6:
2749 for (n = 0; n < 16; n++) {
2750 if ((inaddr6->s6_addr[n] & cidr[i].u.in6.mask.s6_addr[n])
2751 != cidr[i].u.in6.addr.s6_addr[n])
2752 {
2753 goto next;
2754 }
2755 }
2756 break;
2757 #endif
2758
2759 #if (NGX_HAVE_UNIX_DOMAIN)
2760 case AF_UNIX:
2761 break;
2762 #endif
2763
2764 default: /* AF_INET */
2765 if ((inaddr & cidr[i].u.in.mask) != cidr[i].u.in.addr) {
2766 goto next;
2767 }
2768 break;
2769 }
2770
2771 for (p = xff + xfflen - 1; p > xff; p--, xfflen--) {
2772 if (*p != ' ' && *p != ',') {
2773 break;
2774 }
2775 }
2776
2777 for ( /* void */ ; p > xff; p--) {
2778 if (*p == ' ' || *p == ',') {
2779 p++;
2780 break;
2781 }
2782 }
2783
2784 if (ngx_parse_addr(r->pool, &paddr, p, xfflen - (p - xff)) != NGX_OK) {
2785 return NGX_DECLINED;
2786 }
2787
2788 *addr = paddr;
2789
2790 if (recursive && p > xff) {
2791 (void) ngx_http_get_forwarded_addr(r, addr, xff, p - 1 - xff,
2792 proxies, 1);
2793 }
2794
2795 return NGX_OK;
2796
2797 next:
2798 continue;
2799 }
2800
2801 return NGX_DECLINED;
2698 } 2802 }
2699 2803
2700 2804
2701 static char * 2805 static char *
2702 ngx_http_core_server(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy) 2806 ngx_http_core_server(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)