comparison src/http/modules/ngx_http_proxy_module.c @ 648:f200748c0ac8 NGINX_1_1_8

nginx 1.1.8 *) Change: the ngx_http_limit_zone_module was renamed to the ngx_http_limit_conn_module. *) Change: the "limit_zone" directive was superseded by the "limit_conn_zone" directive with a new syntax. *) Feature: support for multiple "limit_conn" limits on the same level. *) Feature: the "image_filter_sharpen" directive. *) Bugfix: a segmentation fault might occur in a worker process if resolver got a big DNS response. Thanks to Ben Hawkes. *) Bugfix: in cache key calculation if internal MD5 implementation was used; the bug had appeared in 1.0.4. *) Bugfix: the "If-Modified-Since", "If-Range", etc. client request header lines might be passed to backend while caching; or not passed without caching if caching was enabled in another part of the configuration. *) Bugfix: the module ngx_http_mp4_module sent incorrect "Content-Length" response header line if the "start" argument was used. Thanks to Piotr Sikora.
author Igor Sysoev <http://sysoev.ru>
date Mon, 14 Nov 2011 00:00:00 +0400
parents 6f21ae02fb01
children 753f505670e0
comparison
equal deleted inserted replaced
647:bec017127243 648:f200748c0ac8
541 static ngx_keyval_t ngx_http_proxy_cache_headers[] = { 541 static ngx_keyval_t ngx_http_proxy_cache_headers[] = {
542 { ngx_string("Host"), ngx_string("$proxy_host") }, 542 { ngx_string("Host"), ngx_string("$proxy_host") },
543 { ngx_string("Connection"), ngx_string("close") }, 543 { ngx_string("Connection"), ngx_string("close") },
544 { ngx_string("Keep-Alive"), ngx_string("") }, 544 { ngx_string("Keep-Alive"), ngx_string("") },
545 { ngx_string("Expect"), ngx_string("") }, 545 { ngx_string("Expect"), ngx_string("") },
546 { ngx_string("Upgrade"), ngx_string("") },
546 { ngx_string("If-Modified-Since"), ngx_string("") }, 547 { ngx_string("If-Modified-Since"), ngx_string("") },
547 { ngx_string("If-Unmodified-Since"), ngx_string("") }, 548 { ngx_string("If-Unmodified-Since"), ngx_string("") },
548 { ngx_string("If-None-Match"), ngx_string("") }, 549 { ngx_string("If-None-Match"), ngx_string("") },
549 { ngx_string("If-Match"), ngx_string("") }, 550 { ngx_string("If-Match"), ngx_string("") },
550 { ngx_string("Range"), ngx_string("") }, 551 { ngx_string("Range"), ngx_string("") },
2491 ngx_http_proxy_loc_conf_t *prev = parent; 2492 ngx_http_proxy_loc_conf_t *prev = parent;
2492 ngx_http_proxy_loc_conf_t *conf = child; 2493 ngx_http_proxy_loc_conf_t *conf = child;
2493 2494
2494 u_char *p; 2495 u_char *p;
2495 size_t size; 2496 size_t size;
2496 ngx_keyval_t *s;
2497 ngx_hash_init_t hash; 2497 ngx_hash_init_t hash;
2498 ngx_http_core_loc_conf_t *clcf; 2498 ngx_http_core_loc_conf_t *clcf;
2499 ngx_http_proxy_redirect_t *pr; 2499 ngx_http_proxy_redirect_t *pr;
2500 ngx_http_script_compile_t sc; 2500 ngx_http_script_compile_t sc;
2501 2501
2839 sc.complete_values = 1; 2839 sc.complete_values = 1;
2840 2840
2841 if (ngx_http_script_compile(&sc) != NGX_OK) { 2841 if (ngx_http_script_compile(&sc) != NGX_OK) {
2842 return NGX_CONF_ERROR; 2842 return NGX_CONF_ERROR;
2843 } 2843 }
2844
2845 if (conf->headers_source == NULL) {
2846 conf->headers_source = ngx_array_create(cf->pool, 4,
2847 sizeof(ngx_keyval_t));
2848 if (conf->headers_source == NULL) {
2849 return NGX_CONF_ERROR;
2850 }
2851 }
2852
2853 s = ngx_array_push(conf->headers_source);
2854 if (s == NULL) {
2855 return NGX_CONF_ERROR;
2856 }
2857
2858 ngx_str_set(&s->key, "Content-Length");
2859 ngx_str_set(&s->value, "$proxy_internal_body_length");
2860 } 2844 }
2861 2845
2862 if (ngx_http_proxy_merge_headers(cf, conf, prev) != NGX_OK) { 2846 if (ngx_http_proxy_merge_headers(cf, conf, prev) != NGX_OK) {
2863 return NGX_CONF_ERROR; 2847 return NGX_CONF_ERROR;
2864 } 2848 }
2873 { 2857 {
2874 u_char *p; 2858 u_char *p;
2875 size_t size; 2859 size_t size;
2876 uintptr_t *code; 2860 uintptr_t *code;
2877 ngx_uint_t i; 2861 ngx_uint_t i;
2878 ngx_array_t headers_names; 2862 ngx_array_t headers_names, headers_merged;
2879 ngx_keyval_t *src, *s, *h; 2863 ngx_keyval_t *src, *s, *h;
2880 ngx_hash_key_t *hk; 2864 ngx_hash_key_t *hk;
2881 ngx_hash_init_t hash; 2865 ngx_hash_init_t hash;
2882 ngx_http_script_compile_t sc; 2866 ngx_http_script_compile_t sc;
2883 ngx_http_script_copy_code_t *copy; 2867 ngx_http_script_copy_code_t *copy;
2889 conf->headers_set_hash = prev->headers_set_hash; 2873 conf->headers_set_hash = prev->headers_set_hash;
2890 conf->headers_source = prev->headers_source; 2874 conf->headers_source = prev->headers_source;
2891 } 2875 }
2892 2876
2893 if (conf->headers_set_hash.buckets 2877 if (conf->headers_set_hash.buckets
2878 && ((conf->body_source.data == NULL)
2879 == (prev->body_source.data == NULL))
2894 #if (NGX_HTTP_CACHE) 2880 #if (NGX_HTTP_CACHE)
2895 && ((conf->upstream.cache == NULL) == (prev->upstream.cache == NULL)) 2881 && ((conf->upstream.cache == NULL) == (prev->upstream.cache == NULL))
2896 #endif 2882 #endif
2897 ) 2883 )
2898 { 2884 {
2904 != NGX_OK) 2890 != NGX_OK)
2905 { 2891 {
2906 return NGX_ERROR; 2892 return NGX_ERROR;
2907 } 2893 }
2908 2894
2895 if (ngx_array_init(&headers_merged, cf->temp_pool, 4, sizeof(ngx_keyval_t))
2896 != NGX_OK)
2897 {
2898 return NGX_ERROR;
2899 }
2900
2909 if (conf->headers_source == NULL) { 2901 if (conf->headers_source == NULL) {
2910 conf->headers_source = ngx_array_create(cf->pool, 4, 2902 conf->headers_source = ngx_array_create(cf->pool, 4,
2911 sizeof(ngx_keyval_t)); 2903 sizeof(ngx_keyval_t));
2912 if (conf->headers_source == NULL) { 2904 if (conf->headers_source == NULL) {
2913 return NGX_ERROR; 2905 return NGX_ERROR;
2923 if (conf->headers_set == NULL) { 2915 if (conf->headers_set == NULL) {
2924 return NGX_ERROR; 2916 return NGX_ERROR;
2925 } 2917 }
2926 2918
2927 2919
2928 src = conf->headers_source->elts;
2929
2930 #if (NGX_HTTP_CACHE) 2920 #if (NGX_HTTP_CACHE)
2931 2921
2932 h = conf->upstream.cache ? ngx_http_proxy_cache_headers: 2922 h = conf->upstream.cache ? ngx_http_proxy_cache_headers:
2933 ngx_http_proxy_headers; 2923 ngx_http_proxy_headers;
2934 #else 2924 #else
2935 2925
2936 h = ngx_http_proxy_headers; 2926 h = ngx_http_proxy_headers;
2937 2927
2938 #endif 2928 #endif
2939 2929
2930 src = conf->headers_source->elts;
2931 for (i = 0; i < conf->headers_source->nelts; i++) {
2932
2933 s = ngx_array_push(&headers_merged);
2934 if (s == NULL) {
2935 return NGX_ERROR;
2936 }
2937
2938 *s = src[i];
2939 }
2940
2940 while (h->key.len) { 2941 while (h->key.len) {
2941 2942
2942 for (i = 0; i < conf->headers_source->nelts; i++) { 2943 src = headers_merged.elts;
2944 for (i = 0; i < headers_merged.nelts; i++) {
2943 if (ngx_strcasecmp(h->key.data, src[i].key.data) == 0) { 2945 if (ngx_strcasecmp(h->key.data, src[i].key.data) == 0) {
2944 goto next; 2946 goto next;
2945 } 2947 }
2946 } 2948 }
2947 2949
2948 s = ngx_array_push(conf->headers_source); 2950 s = ngx_array_push(&headers_merged);
2949 if (s == NULL) { 2951 if (s == NULL) {
2950 return NGX_ERROR; 2952 return NGX_ERROR;
2951 } 2953 }
2952 2954
2953 *s = *h; 2955 *s = *h;
2954 2956
2955 src = conf->headers_source->elts;
2956
2957 next: 2957 next:
2958 2958
2959 h++; 2959 h++;
2960 } 2960 }
2961 2961
2962 2962 if (conf->body_source.data) {
2963 src = conf->headers_source->elts; 2963 s = ngx_array_push(&headers_merged);
2964 for (i = 0; i < conf->headers_source->nelts; i++) { 2964 if (s == NULL) {
2965 return NGX_ERROR;
2966 }
2967
2968 ngx_str_set(&s->key, "Content-Length");
2969 ngx_str_set(&s->value, "$proxy_internal_body_length");
2970 }
2971
2972
2973 src = headers_merged.elts;
2974 for (i = 0; i < headers_merged.nelts; i++) {
2965 2975
2966 hk = ngx_array_push(&headers_names); 2976 hk = ngx_array_push(&headers_names);
2967 if (hk == NULL) { 2977 if (hk == NULL) {
2968 return NGX_ERROR; 2978 return NGX_ERROR;
2969 } 2979 }