comparison src/http/ngx_http_upstream.c @ 212:56688ed172c8 NGINX_0_3_53

nginx 0.3.53 *) Change: the "add_header" directive adds the string to 204, 301, and 302 responses. *) Feature: the "server" directive in the "upstream" context supports the "weight" parameter. *) Feature: the "server_name" directive supports the "*" wildcard. *) Feature: nginx supports the request body size more than 2G. *) Bugfix: if a client was successfully authorized using "satisfy_any on", then anyway the message "access forbidden by rule" was written in the log. *) Bugfix: the "PUT" method may erroneously not create a file and return the 409 code. *) Bugfix: if the IMAP/POP3 backend returned an error, then nginx continued proxying anyway.
author Igor Sysoev <http://sysoev.ru>
date Fri, 07 Jul 2006 00:00:00 +0400
parents b12b3b1a9426
children 0ad9eeb6ac7f
comparison
equal deleted inserted replaced
211:f04a54878110 212:56688ed172c8
224 0, 224 0,
225 0, 225 0,
226 NULL }, 226 NULL },
227 227
228 { ngx_string("server"), 228 { ngx_string("server"),
229 NGX_HTTP_UPS_CONF|NGX_CONF_TAKE1, 229 NGX_HTTP_UPS_CONF|NGX_CONF_TAKE12,
230 ngx_http_upstream_server, 230 ngx_http_upstream_server,
231 NGX_HTTP_SRV_CONF_OFFSET, 231 NGX_HTTP_SRV_CONF_OFFSET,
232 0, 232 0,
233 NULL }, 233 NULL },
234 234
2727 if (uscf->peers == NULL) { 2727 if (uscf->peers == NULL) {
2728 return NGX_CONF_ERROR; 2728 return NGX_CONF_ERROR;
2729 } 2729 }
2730 2730
2731 uscf->peers->number = n; 2731 uscf->peers->number = n;
2732 uscf->peers->weight = 1;
2733 2732
2734 n = 0; 2733 n = 0;
2735 2734
2736 for (i = 0; i < uscf->servers->nelts; i++) { 2735 for (i = 0; i < uscf->servers->nelts; i++) {
2737 for (j = 0; j < peers[i]->number; j++) { 2736 for (j = 0; j < peers[i]->number; j++) {
2748 { 2747 {
2749 ngx_http_upstream_srv_conf_t *uscf = conf; 2748 ngx_http_upstream_srv_conf_t *uscf = conf;
2750 2749
2751 ngx_str_t *value; 2750 ngx_str_t *value;
2752 ngx_url_t u; 2751 ngx_url_t u;
2752 ngx_int_t weight;
2753 ngx_uint_t i;
2753 ngx_peers_t **peers; 2754 ngx_peers_t **peers;
2754 2755
2755 if (uscf->servers == NULL) { 2756 if (uscf->servers == NULL) {
2756 uscf->servers = ngx_array_create(cf->pool, 4, sizeof(ngx_peers_t *)); 2757 uscf->servers = ngx_array_create(cf->pool, 4, sizeof(ngx_peers_t *));
2757 if (uscf->servers == NULL) { 2758 if (uscf->servers == NULL) {
2778 } 2779 }
2779 2780
2780 return NGX_CONF_ERROR; 2781 return NGX_CONF_ERROR;
2781 } 2782 }
2782 2783
2784 weight = 1;
2785
2786 if (cf->args->nelts == 3) {
2787
2788 value = &value[2];
2789
2790 if (ngx_strncmp(value->data, "weight=", 7) == 0) {
2791
2792 weight = ngx_atoi(&value->data[7], value->len - 7);
2793
2794 if (weight == NGX_ERROR || weight == 0) {
2795 goto invalid;
2796 }
2797
2798 } else {
2799 goto invalid;
2800 }
2801 }
2802
2803 for (i = 0; i < u.peers->number; i++) {
2804 u.peers->peer[i].weight = weight;
2805 u.peers->peer[i].current_weight = weight;
2806 u.peers->peer[i].max_fails = NGX_CONF_UNSET_UINT;
2807 u.peers->peer[i].fail_timeout = NGX_CONF_UNSET;
2808 }
2809
2783 *peers = u.peers; 2810 *peers = u.peers;
2784 2811
2785 return NGX_CONF_OK; 2812 return NGX_CONF_OK;
2813
2814 invalid:
2815
2816 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "invalid parameter \"%V\"", value);
2817
2818 return NGX_CONF_ERROR;
2786 } 2819 }
2787 2820
2788 2821
2789 ngx_http_upstream_srv_conf_t * 2822 ngx_http_upstream_srv_conf_t *
2790 ngx_http_upstream_add(ngx_conf_t *cf, ngx_url_t *u) 2823 ngx_http_upstream_add(ngx_conf_t *cf, ngx_url_t *u)
2891 if (uscfp[i]->peers) { 2924 if (uscfp[i]->peers) {
2892 continue; 2925 continue;
2893 } 2926 }
2894 2927
2895 uscfp[i]->peers = ngx_inet_resolve_peer(cf, &uscfp[i]->host, 2928 uscfp[i]->peers = ngx_inet_resolve_peer(cf, &uscfp[i]->host,
2896 uscfp[i]->port); 2929 uscfp[i]->port);
2897
2898 if (uscfp[i]->peers == NULL) { 2930 if (uscfp[i]->peers == NULL) {
2899 return NGX_CONF_ERROR; 2931 return NGX_CONF_ERROR;
2900 } 2932 }
2901 2933
2902 if (uscfp[i]->peers == NGX_CONF_ERROR) { 2934 if (uscfp[i]->peers == NGX_CONF_ERROR) {
2905 &uscfp[i]->host, uscfp[i]->file_name.data, 2937 &uscfp[i]->host, uscfp[i]->file_name.data,
2906 uscfp[i]->line); 2938 uscfp[i]->line);
2907 return NGX_CONF_ERROR; 2939 return NGX_CONF_ERROR;
2908 } 2940 }
2909 } 2941 }
2942
2910 2943
2911 if (ngx_array_init(&headers_in, cf->temp_pool, 32, sizeof(ngx_hash_key_t)) 2944 if (ngx_array_init(&headers_in, cf->temp_pool, 32, sizeof(ngx_hash_key_t))
2912 != NGX_OK) 2945 != NGX_OK)
2913 { 2946 {
2914 return NGX_CONF_ERROR; 2947 return NGX_CONF_ERROR;